Class: RemoteResource::ConnectionOptions

Inherits:
Object
  • Object
show all
Defined in:
lib/remote_resource/connection_options.rb

Constant Summary collapse

AVAILABLE_OPTIONS =
[:site, :headers, :default_headers, :version, :path_prefix, :path_postfix, :collection_prefix, :extension, :collection, :collection_name, :root_element].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(base_class) ⇒ ConnectionOptions

Returns a new instance of ConnectionOptions.



8
9
10
11
# File 'lib/remote_resource/connection_options.rb', line 8

def initialize(base_class)
  @base_class = base_class
  self.send :initialize_connection_options
end

Instance Attribute Details

#base_classObject (readonly)

Returns the value of attribute base_class.



6
7
8
# File 'lib/remote_resource/connection_options.rb', line 6

def base_class
  @base_class
end

Instance Method Details

#merge(options = {}) ⇒ Object



13
14
15
16
17
# File 'lib/remote_resource/connection_options.rb', line 13

def merge(options = {})
  options.each do |option, value|
    self.public_send "#{option}=", value
  end and self
end

#reloadObject



25
26
27
# File 'lib/remote_resource/connection_options.rb', line 25

def reload
  initialize_connection_options
end

#reload!Object



29
30
31
# File 'lib/remote_resource/connection_options.rb', line 29

def reload!
  reload and self
end

#to_hashObject



19
20
21
22
23
# File 'lib/remote_resource/connection_options.rb', line 19

def to_hash
  AVAILABLE_OPTIONS.each_with_object(Hash.new) do |option, hash|
    hash[option] = self.public_send option
  end
end