lib/botfly/responder/responder.rb in botfly-0.1.1 vs lib/botfly/responder/responder.rb in botfly-0.2.1
- old
+ new
@@ -1,25 +1,31 @@
module Botfly
class Responder
- attr_reader :callback, :callback_type
+ @@id = 1
+ include Botfly::CommonResponderMethods
+ extend Forwardable
+
+ attr_reader :callback, :callback_type, :id, :bot
+ def_delegator :@bot, :client
- def initialize(client,bot,&block)
+ def initialize(bot,&block)
Botfly.logger.info(" RSP: #{self.class.to_s}#new")
@matcher_chain = []
@bot = bot
- @client = client
@callback = block if block_given?
+ @id = @@id += 1
end
def method_missing(method,condition,&block)
Botfly.logger.info(" RSP: Responder##{method}(#{condition.inspect})")
add_matcher(method,condition)
if block_given?
Botfly.logger.info(" RSP: Callback recorded: #{block.inspect}")
- @callback = block
+ @callback = block
+ return @id
end
return self
end
@@ -44,16 +50,11 @@
klass = Botfly.const_get(method.to_s.capitalize + "Matcher")
@matcher_chain << klass.new(condition)
Botfly.logger.debug(" RSP: Adding to matcher chain: #{@matcher_chain.inspect}")
end
-
- # TODO: Check callback is in acceptable list - MUC subclass can override this list
- def register_with_bot(callback_type)
- raise "AbstractMethodError: You must implement this method in a concrete subclass"
- end
def setup_instance_variables(params)
raise "AbstractMethodError: You must implement this method in a concrete subclass"
end
end
-end
\ No newline at end of file
+end