Class: PincasterPin

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pin_hash) ⇒ PincasterPin

Returns a new instance of PincasterPin.



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

def initialize(pin_hash)
  @pin_hash = pin_hash
  splat_pin
end

Instance Attribute Details

#pin_hashObject (readonly)

Returns the value of attribute pin_hash.



3
4
5
# File 'lib/pincaster_pin.rb', line 3

def pin_hash
  @pin_hash
end

Instance Method Details

#idObject

returns the ActiveRecord:id of this pin’s matching ActiveRecord object



19
20
21
# File 'lib/pincaster_pin.rb', line 19

def id
  key
end

#splat_pinObject

provides an accessor for every pin value that came back from Pincaster



11
12
13
14
15
16
# File 'lib/pincaster_pin.rb', line 11

def splat_pin
  @pin_hash.each_pair do |key, value|
    self.class.send(:attr_accessor, key.to_sym)
    self.send(key.to_s + "=", value)
  end
end