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 |
# 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.deliver instance.envelope end |
Instance Method Details
#action_methods ⇒ Object
31 32 33 |
# File 'lib/action_push/concerns/class_method_delivery.rb', line 31 def action_methods @action_methods ||= public_instance_methods(false).to_set end |
#respond_to_missing?(method_name, include_private = false) ⇒ Boolean
27 28 29 |
# File 'lib/action_push/concerns/class_method_delivery.rb', line 27 def respond_to_missing?(method_name, include_private = false) action_methods.include?(method_name) || super end |