Class: GoodDataMarketo::MObject
- Inherits:
-
Object
- Object
- GoodDataMarketo::MObject
- Defined in:
- lib/gooddata_marketo/models/child/mobj.rb
Instance Method Summary collapse
- #attributes(a = nil) ⇒ Object
- #headers ⇒ Object
- #id ⇒ Object
-
#initialize(data, config = {}) ⇒ MObject
constructor
A new instance of MObject.
- #raw ⇒ Object (also: #json)
- #to_row ⇒ Object (also: #to_a)
- #type ⇒ Object (also: #object_type)
Constructor Details
#initialize(data, config = {}) ⇒ MObject
Returns a new instance of MObject.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/gooddata_marketo/models/child/mobj.rb', line 5 def initialize data, config = {} @object = { :type => data[:type], :id => data[:id], :raw => data } @headers = @object.keys.map{|k| k.to_s.capitalize! } @headers.pop() attributes = data[:attrib_list][:attrib] attribute_map = Hash.new attributes.map { |attr| @headers << property = attr[:name] value = attr[:value] attribute_map[property] = value } @attributes = attribute_map end |
Instance Method Details
#attributes(a = nil) ⇒ Object
48 49 50 51 52 53 54 55 56 |
# File 'lib/gooddata_marketo/models/child/mobj.rb', line 48 def attributes a = nil if a @attributes[a] else @attributes end end |
#headers ⇒ Object
40 41 42 |
# File 'lib/gooddata_marketo/models/child/mobj.rb', line 40 def headers @headers end |
#id ⇒ Object
44 45 46 |
# File 'lib/gooddata_marketo/models/child/mobj.rb', line 44 def id @object[:id] end |
#raw ⇒ Object Also known as: json
58 59 60 |
# File 'lib/gooddata_marketo/models/child/mobj.rb', line 58 def raw @activity[:raw] end |
#to_row ⇒ Object Also known as: to_a
32 33 34 35 36 37 38 |
# File 'lib/gooddata_marketo/models/child/mobj.rb', line 32 def to_row row = [self.id,self.time,self.type,self.name] @attributes.each do |attr| row << attr[1] end row.map! { |i| i.to_s } end |
#type ⇒ Object Also known as: object_type
28 29 30 |
# File 'lib/gooddata_marketo/models/child/mobj.rb', line 28 def type @object[:type] end |