Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

tmf_common

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tmf_common

  • 0.0.2
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

TMF 公共模块

Validators(Model验证)

  • mobile_phone (验证手机号)

Publisher/Subscriber (消息订阅)

使用场景:统计登录失败的频率,统计某个页面的访问

使用方法:

定义一个消息发布器Publisher

class AccountEvent
    include TmfCommon::Publisher
    self.publisher_namespace = 'account'
end

定义一个消息订阅器Subscriber

class AccountEventSubscriber < TmfCommon::Subscriber
    self.attach_to 'account'
    def login(event)
        puts "#{event.payload[:user]} login at #{event.payload[:time]}"
    end
end

开始发送消息:

[7] pry(main)> AccountEvent.broadcast_event 'login', user: 'xiaohui', time: Time.now
xiaohui login at 2017-03-13 17:12:57 +0800
=> nil

FAQs

Package last updated on 15 Sep 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc