Module: Dobedobedo::ObjToJson

Included in:
Note, Project, Task, User
Defined in:
lib/dobedobedo/objToJson.rb

Instance Method Summary collapse

Instance Method Details

#obj_to_jsonObject

def to_json(*a)

objToJson.to_json(*a)

end



20
21
22
23
24
25
26
27
28
29
# File 'lib/dobedobedo/objToJson.rb', line 20

def obj_to_json
  retval = {}
  instance_variables.each do |ivar| 
    i = instance_variable_get ivar.to_sym
    propname = ivar[1..-1]
    next if %w{token lock_version accepted deleted closed recurrence timed closed_at due_at type goal comments_count updated_at workspace_id assignee created_at comments user creator requestor followers attachments attachments_count notes contacts}.include? propname
    retval[propname] = (i.respond_to? :obj_to_json) ? i.obj_to_json : i;
  end
  retval.to_json
end

#obj_to_json2Object



31
32
33
# File 'lib/dobedobedo/objToJson.rb', line 31

def obj_to_json2
  {:id=>@id, :name => @name, :description => @description}
end

#objToJsonObject



5
6
7
8
9
10
11
12
13
14
# File 'lib/dobedobedo/objToJson.rb', line 5

def objToJson
  h = {}
  instance_variables.each do |e|
    #next unless [@workspace_id, @id, @lock_version, @name, @description, @due_at, @closed_at, @created_at, @updated_at, @comments_count, @timed, @accepted, @recurrence, @deleted, @closed].include? e.to_sym
    next if [:@token].include? e.to_sym
    o = instance_variable_get e.to_sym
    h[e[1..-1]] = (o.respond_to? :objToJson) ? o.objToJson : o;
  end
  h
end