Class: MoonropeClient::Controller
- Inherits:
-
Object
- Object
- MoonropeClient::Controller
- Defined in:
- lib/moonrope_client/controller.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#initialize(connection, controller_name) ⇒ Controller
constructor
A new instance of Controller.
- #method_missing(name, params = {}) ⇒ Object
- #request(action_name, params = {}) ⇒ Object
Constructor Details
#initialize(connection, controller_name) ⇒ Controller
Returns a new instance of Controller.
4 5 6 7 |
# File 'lib/moonrope_client/controller.rb', line 4 def initialize(connection, controller_name) @connection = connection @controller_name = controller_name end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, params = {}) ⇒ Object
11 12 13 |
# File 'lib/moonrope_client/controller.rb', line 11 def method_missing(name, params = {}) request(name, params) end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
9 10 11 |
# File 'lib/moonrope_client/controller.rb', line 9 def name @name end |
Instance Method Details
#request(action_name, params = {}) ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/moonrope_client/controller.rb', line 15 def request(action_name, params = {}) if action_name =~ /\A(.*)\!\z/ @connection.request!(@controller_name, $1, params) else @connection.request(@controller_name, action_name, params) end end |