Class: Megam::Crm

Inherits:
Object
  • Object
show all
Defined in:
lib/megam/core/crm.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeCrm

Returns a new instance of Crm.



18
19
20
# File 'lib/megam/core/crm.rb', line 18

def initialize
  @json = nil      
end

Class Method Details

.create(o) ⇒ Object



66
67
68
69
70
71
# File 'lib/megam/core/crm.rb', line 66

def self.create(o)
  puts "self.create entry"
  puts o
  acct = from_hash(o)
  acct.create
end

.from_hash(o) ⇒ Object



53
54
55
56
57
58
# File 'lib/megam/core/crm.rb', line 53

def self.from_hash(o)
  puts "self from_hash entry"
  acct = self.new()
  acct.from_hash(o)
  acct
end

Instance Method Details

#createObject

Create the node via the REST API



74
75
76
77
78
# File 'lib/megam/core/crm.rb', line 74

def create
  puts "crm create entry"
  puts to_hash
  megam_rest.post_crm(to_hash)      
end

#crmObject

used by resque workers and any other background job



23
24
25
# File 'lib/megam/core/crm.rb', line 23

def crm
  self
end

#error?Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/megam/core/crm.rb', line 40

def error?
  crocked  = true if (some_msg.has_key?(:msg_type) && some_msg[:msg_type] == "error")
end

#from_hash(o) ⇒ Object



60
61
62
63
64
# File 'lib/megam/core/crm.rb', line 60

def from_hash(o)
  puts "from_hash entry"
  @json = o[:json] if o.has_key?(:json)     
  self
end

#json(arg = nil) ⇒ Object



32
33
34
35
36
37
38
# File 'lib/megam/core/crm.rb', line 32

def json(arg=nil)
  if arg != nil
    @json = arg
  else
  @json
  end
end

#megam_restObject



27
28
29
30
# File 'lib/megam/core/crm.rb', line 27

def megam_rest
  puts "megam_rest entry"     
  Megam::Deccanplato.new
end

#to_hashObject

Transform the ruby obj -> to a Hash



45
46
47
48
49
50
51
# File 'lib/megam/core/crm.rb', line 45

def to_hash
  puts "to_hash entry"
  puts json
  index_hash = Hash.new      
  index_hash[:json] = json      
  index_hash
end

#to_sObject



80
81
82
83
# File 'lib/megam/core/crm.rb', line 80

def to_s
  puts "to_s entry"
  Megam::Stuff.styled_hash(to_hash)
end