Class: GoodDataMarketo::MObject

Inherits:
Object
  • Object
show all
Defined in:
lib/gooddata_marketo/models/child/mobj.rb

Instance Method Summary collapse

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

#headersObject



40
41
42
# File 'lib/gooddata_marketo/models/child/mobj.rb', line 40

def headers
  @headers
end

#idObject



44
45
46
# File 'lib/gooddata_marketo/models/child/mobj.rb', line 44

def id
  @object[:id]
end

#rawObject Also known as: json



58
59
60
# File 'lib/gooddata_marketo/models/child/mobj.rb', line 58

def raw
  @activity[:raw]
end

#to_rowObject 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

#typeObject Also known as: object_type



28
29
30
# File 'lib/gooddata_marketo/models/child/mobj.rb', line 28

def type
  @object[:type]
end