Module: Orthrus::ClassMethods
- Defined in:
- lib/orthrus.rb
Instance Attribute Summary collapse
-
#remote_defaults ⇒ Hash
Define default settings for the remote connection.
Instance Method Summary collapse
-
#call_remote_method(method_name, args) ⇒ Object
Find the specified remote method and pass the arguments.
-
#define_remote_method(name, options = {}) ⇒ Object
Declare a remote method and create a class method as wrapper.
-
#inherited(child) ⇒ Object
If we get subclassed, make sure that child inherits the remote defaults of the parent class.
-
#remote_options ⇒ RemoteOptions
Getter for remote options.
Instance Attribute Details
#remote_defaults ⇒ Hash
Define default settings for the remote connection.
22 23 24 |
# File 'lib/orthrus.rb', line 22 def remote_defaults() .smart_merge!() end |
Instance Method Details
#call_remote_method(method_name, args) ⇒ Object
Find the specified remote method and pass the arguments
49 50 51 52 |
# File 'lib/orthrus.rb', line 49 def call_remote_method(method_name, args) remote_method = @remote_methods[method_name] remote_method.run(args) end |
#define_remote_method(name, options = {}) ⇒ Object
Declare a remote method and create a class method as wrapper
35 36 37 38 39 40 41 42 43 44 |
# File 'lib/orthrus.rb', line 35 def define_remote_method(name, = {}) @remote_methods ||= {} @remote_methods[name] = RemoteMethod.new(.smart_merge()) class_eval <<-SRC def self.#{name.to_s}(args = {}) call_remote_method(:#{name.to_s}, args) end SRC end |
#inherited(child) ⇒ Object
If we get subclassed, make sure that child inherits the remote defaults of the parent class.
28 29 30 |
# File 'lib/orthrus.rb', line 28 def inherited(child) child.__send__(:remote_defaults, ) end |
#remote_options ⇒ RemoteOptions
Getter for remote options
14 15 16 |
# File 'lib/orthrus.rb', line 14 def @remote_options ||= RemoteOptions.new end |