Class: NationBuilder::Endpoint

Inherits:
Object
  • Object
show all
Defined in:
lib/nationbuilder/endpoint.rb

Defined Under Namespace

Classes: InvalidMethod

Instance Method Summary collapse

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

Raises:



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

#methodsObject



16
17
18
# File 'lib/nationbuilder/endpoint.rb', line 16

def methods
  @methods ||= @name_to_method.keys
end

#nameObject



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