Class: NationBuilder::Endpoint
- Inherits:
-
Object
- Object
- NationBuilder::Endpoint
- Defined in:
- lib/nationbuilder/endpoint.rb
Defined Under Namespace
Classes: InvalidMethod
Instance Method Summary collapse
- #[](method_name) ⇒ Object
-
#initialize(name) ⇒ Endpoint
constructor
A new instance of Endpoint.
- #methods ⇒ Object
- #name ⇒ Object
- #register_method(method) ⇒ Object
Constructor Details
#initialize(name) ⇒ Endpoint
Returns a new instance of Endpoint.
3 4 5 6 |
# File 'lib/nationbuilder/endpoint.rb', line 3 def initialize(name) @name = name @name_to_method = {} end |
Instance Method Details
#[](method_name) ⇒ Object
22 23 24 25 26 |
# File 'lib/nationbuilder/endpoint.rb', line 22 def [](method_name) m = @name_to_method[method_name] raise InvalidMethod.new(method_name) if m.nil? m end |
#methods ⇒ Object
16 17 18 |
# File 'lib/nationbuilder/endpoint.rb', line 16 def methods @methods ||= @name_to_method.keys end |
#name ⇒ Object
8 9 10 |
# File 'lib/nationbuilder/endpoint.rb', line 8 def name @name.downcase.gsub(' ', '_').to_sym end |
#register_method(method) ⇒ Object
12 13 14 |
# File 'lib/nationbuilder/endpoint.rb', line 12 def register_method(method) @name_to_method[method.name] = method end |