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.
23 24 25 |
# File 'lib/orthrus.rb', line 23 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
50 51 52 53 |
# File 'lib/orthrus.rb', line 50 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
36 37 38 39 40 41 42 43 44 45 |
# File 'lib/orthrus.rb', line 36 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.
29 30 31 |
# File 'lib/orthrus.rb', line 29 def inherited(child) child.__send__(:remote_defaults, ) end |
#remote_options ⇒ RemoteOptions
Getter for remote options
15 16 17 |
# File 'lib/orthrus.rb', line 15 def @remote_options ||= RemoteOptions.new end |