Module: OpenCivicData

Extended by:
OpenCivicData
Included in:
OpenCivicData
Defined in:
lib/open_civic_data.rb,
lib/open_civic_data/client.rb,
lib/open_civic_data/version.rb,
lib/open_civic_data/request.rb,
lib/open_civic_data/connection.rb

Defined Under Namespace

Modules: Connection, Request Classes: Client

Constant Summary collapse

VERSION =
'0.0.4'

Instance Attribute Summary collapse

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object

Delegate to OpenCivicData::Client


17
18
19
20
# File 'lib/open_civic_data.rb', line 17

def method_missing(method, *args, &block)
  return super unless new.respond_to?(method)
  new.send(method, *args, &block)
end

Instance Attribute Details

#keyObject

Returns the value of attribute key


5
6
7
# File 'lib/open_civic_data.rb', line 5

def key
  @key
end

Instance Method Details

#new(key = key) {|_self| ... } ⇒ OpenCivicData::Client

Alias for OpenCivicData::Client.new

Yields:

  • (_self)

Yield Parameters:

  • _self (OpenCivicData)

    the object that the method was called on


10
11
12
13
14
# File 'lib/open_civic_data.rb', line 10

def new(key = key)
  yield self if block_given?
  return @client if instance_variable_defined?(:@client) && @client.key == key
  @client = OpenCivicData::Client.new(key)
end

#respond_to_missing?(method_name, include_private = false) ⇒ Boolean

return [Boolean]


23
# File 'lib/open_civic_data.rb', line 23

def respond_to_missing?(method_name, include_private = false) new.respond_to?(method_name, include_private) end