Class: Rhoconnect::Client
Instance Attribute Summary collapse
Attributes inherited from Model
#id
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from LockOps
#lock
Methods included from Document
#delete_data, #docname, #flash_data, #flash_source_data, #flush_zdata, #get_data, #get_list, #get_object, #get_value, #get_zdata, #put_data, #put_list, #put_object, #put_value, #put_zdata, #remove_objects, #rename, #update_count, #update_objects
Methods inherited from Model
_field_key, _prefix, class_prefix, #decrement!, field, #field_key, fields, #increment!, #initialize, is_exist?, list, marshal_class_name, #next_id, populate_attributes, #redis, redis, set, #to_array, validates_presence_of
Instance Attribute Details
#source_name ⇒ Object
Returns the value of attribute source_name.
13
14
15
|
# File 'lib/rhoconnect/client.rb', line 13
def source_name
@source_name
end
|
Class Method Details
.create(fields, params = {}) ⇒ Object
.load(id, params) ⇒ Object
33
34
35
36
|
# File 'lib/rhoconnect/client.rb', line 33
def self.load(id,params)
validate_attributes(params)
super(id,params)
end
|
Instance Method Details
#app ⇒ Object
38
39
40
|
# File 'lib/rhoconnect/client.rb', line 38
def app
@app ||= App.load(app_id)
end
|
#doc_suffix(doctype) ⇒ Object
42
43
44
45
46
47
48
49
50
51
|
# File 'lib/rhoconnect/client.rb', line 42
def doc_suffix(doctype)
doctype = doctype.to_s
if doctype == '*'
"#{self.user_id}:#{self.id}:*"
elsif self.source_name
"#{self.user_id}:#{self.id}:#{self.source_name}:#{doctype}"
else
raise InvalidSourceNameError.new('Invalid Source Name For Client')
end
end
|
#switch_user(new_user_id) ⇒ Object
64
65
66
67
68
69
|
# File 'lib/rhoconnect/client.rb', line 64
def switch_user(new_user_id)
flash_data('*')
User.load(self.user_id).clients.delete(self.id)
User.load(new_user_id).clients << self.id
self.user_id = new_user_id
end
|
#update_clientdoc(sources) ⇒ Object
71
72
73
74
75
76
77
78
79
80
81
82
|
# File 'lib/rhoconnect/client.rb', line 71
def update_clientdoc(sources)
sources.each do |source|
s = Source.load(source,{:app_id => app_id,:user_id => user_id})
unless s.sync_type.to_sym == :bulk_sync_only
self.source_name = source
Store.clone(s.docname(:md_copy),self.docname(:cd))
end
self.put_value(:schema_sha1,s.get_value(:schema_sha1))
end
end
|
#update_fields(params) ⇒ Object
84
85
86
87
88
|
# File 'lib/rhoconnect/client.rb', line 84
def update_fields(params)
[:device_type, :device_push_type,:device_pin,:device_port,:phone_id].each do |setting|
self.send "#{setting}=".to_sym, params[setting].to_s if params[setting]
end
end
|