Class: PFS::Resources::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/pfs/resources/base.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response, attributes = {}) ⇒ Base

Returns a new instance of Base.



8
9
10
11
12
13
14
# File 'lib/pfs/resources/base.rb', line 8

def initialize(response, attributes = {})
  @response = response
  attributes.each do |key, value|
    m = "#{key}=".to_sym
    send(m, value) if respond_to?(m)
  end
end

Instance Attribute Details

#responseObject (readonly)

Returns the value of attribute response.



6
7
8
# File 'lib/pfs/resources/base.rb', line 6

def response
  @response
end

Class Method Details

.map(original_attribute, mapped_attributes) ⇒ Object



16
17
18
19
20
21
22
# File 'lib/pfs/resources/base.rb', line 16

def self.map(original_attribute, mapped_attributes)
  class_eval { attr_writer original_attribute.to_sym }
  mapped_attributes = [mapped_attributes].flatten
  mapped_attributes.each do |mapped_attribute|
    define_method(mapped_attribute) { instance_variable_get("@#{original_attribute}")}
  end
end