Module: IfreeSms::Callbacks
- Included in:
- Manager
- Defined in:
- lib/ifree_sms/callbacks.rb
Instance Method Summary collapse
-
#_incoming_message ⇒ Object
Provides access to the callback array for incoming_message :api: private.
-
#_run_callbacks(kind, *args) ⇒ Object
Hook to _run_callbacks asserting for conditions.
-
#incoming_message(options = {}, method = :push, &block) ⇒ Object
A callback that runs after message created Example: IfreeSms::Manager.incoming_message do |env, opts| end.
Instance Method Details
#_incoming_message ⇒ Object
Provides access to the callback array for incoming_message :api: private
29 30 31 |
# File 'lib/ifree_sms/callbacks.rb', line 29 def @_incoming_message ||= [] end |
#_run_callbacks(kind, *args) ⇒ Object
Hook to _run_callbacks asserting for conditions.
5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/ifree_sms/callbacks.rb', line 5 def _run_callbacks(kind, *args) #:nodoc: = args.last # Last callback arg MUST be a Hash send("_#{kind}").each do |callback, conditions| invalid = conditions.find do |key, value| value.is_a?(Array) ? !value.include?([key]) : (value != [key]) end callback.call(*args) unless invalid end end |
#incoming_message(options = {}, method = :push, &block) ⇒ Object
22 23 24 25 |
# File 'lib/ifree_sms/callbacks.rb', line 22 def ( = {}, method = :push, &block) raise BlockNotGiven unless block_given? .send(method, [block, ]) end |