Module: ActionPush::Concerns::ClassMethodDelivery
- Included in:
- Base
- Defined in:
- lib/action_push/concerns/class_method_delivery.rb
Instance Method Summary collapse
- #action_methods ⇒ Object
-
#method_missing(method, *argv, &block) ⇒ Envelope
Acts like ActionMailer::Base.
- #respond_to_missing?(method_name, include_private = false) ⇒ Boolean
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *argv, &block) ⇒ Envelope
Acts like ActionMailer::Base
class ApplePush < ActionPush
def welcome
# ....
end
end
ApplePush.new.welcome will build PUSH message, but not send it ApplePush.welcome will build PUSH message and DELIVER it
18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/action_push/concerns/class_method_delivery.rb', line 18 def method_missing(method, *argv, &block) return super unless action_methods.include?(method) instance = new(action_name: method) instance.public_send(method, *argv, &block) instance.envelope.pushes.each do |provider, push| interceptor.call(instance, provider, push) do push.deliver end end instance.envelope end |
Instance Method Details
#action_methods ⇒ Object
36 37 38 |
# File 'lib/action_push/concerns/class_method_delivery.rb', line 36 def action_methods @action_methods ||= public_instance_methods(false).to_set end |
#respond_to_missing?(method_name, include_private = false) ⇒ Boolean
32 33 34 |
# File 'lib/action_push/concerns/class_method_delivery.rb', line 32 def respond_to_missing?(method_name, include_private = false) action_methods.include?(method_name) || super end |