Class: Insightly::BaseData
- Inherits:
-
Object
- Object
- Insightly::BaseData
show all
- Defined in:
- lib/insightly/base_data.rb
Class Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
Returns a new instance of BaseData.
24
25
26
|
# File 'lib/insightly/base_data.rb', line 24
def initialize
@data = {}
end
|
Class Attribute Details
.api_fields ⇒ Object
Returns the value of attribute api_fields.
4
5
6
|
# File 'lib/insightly/base_data.rb', line 4
def api_fields
@api_fields
end
|
Class Method Details
.api_field(*args) ⇒ Object
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
# File 'lib/insightly/base_data.rb', line 9
def self.api_field(*args)
args.each do |field|
self.api_fields = [] if !self.api_fields
self.api_fields << field
method_name = field.downcase.to_sym
send :define_method, method_name do
@data[field]
end
method_name = "#{field.downcase}=".to_sym
send :define_method, method_name do |value|
@data[field] = value
end
end
end
|
.build(data) ⇒ Object
37
38
39
|
# File 'lib/insightly/base_data.rb', line 37
def self.build(data)
self.new.build(data)
end
|
Instance Method Details
#==(other) ⇒ Object
41
42
43
|
# File 'lib/insightly/base_data.rb', line 41
def ==(other)
self.remote_data == other.remote_data
end
|
#build(data) ⇒ Object
32
33
34
35
|
# File 'lib/insightly/base_data.rb', line 32
def build(data)
@data = data
self
end
|
#remote_data ⇒ Object
45
46
47
|
# File 'lib/insightly/base_data.rb', line 45
def remote_data
@data
end
|
#to_json ⇒ Object
28
29
30
|
# File 'lib/insightly/base_data.rb', line 28
def to_json
@data.to_json
end
|