Class: RSlack::Action
- Inherits:
-
Object
- Object
- RSlack::Action
- Defined in:
- lib/rslack/action.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#bot ⇒ Object
readonly
Returns the value of attribute bot.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(bot) ⇒ Action
constructor
A new instance of Action.
- #memory ⇒ Object
Constructor Details
#initialize(bot) ⇒ Action
Returns a new instance of Action.
27 28 29 |
# File 'lib/rslack/action.rb', line 27 def initialize(bot) @bot = bot end |
Instance Attribute Details
#bot ⇒ Object (readonly)
Returns the value of attribute bot.
25 26 27 |
# File 'lib/rslack/action.rb', line 25 def bot @bot end |
Class Method Details
.route(regexp, **opts, &block) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/rslack/action.rb', line 10 def route(regexp, **opts, &block) case callback = opts[:callback] when nil then opts[:callback] = block when Proc then nil when String, Symbol opts[:callback] = lambda { |msg| send(callback, msg) } end route = OpenStruct.new(**opts.merge(action: self, regexp: regexp)) RSlack::Bot.register(route) end |
Instance Method Details
#memory ⇒ Object
31 32 33 |
# File 'lib/rslack/action.rb', line 31 def memory bot.memory[self.class.name] ||= {} end |