Class: HarvestToInfakt::Resource

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/harvest_to_infakt/resource.rb

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Resource

Returns a new instance of Resource.



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

def initialize(data)
  @data = data
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(m, *args) ⇒ Object



13
14
15
16
17
18
19
20
21
# File 'lib/harvest_to_infakt/resource.rb', line 13

def method_missing(m, *args)
  if m.to_s =~ /(.+)=$/
    @data[$1] = args.first
  elsif @data.has_key?(m.to_s)
    @data[m.to_s]
  else
    super
  end
end

Instance Method Details

#idObject



9
10
11
# File 'lib/harvest_to_infakt/resource.rb', line 9

def id
  @data['id']
end