Class: Rhoconnect::SourceAdapter
- Inherits:
-
Object
- Object
- Rhoconnect::SourceAdapter
show all
- Defined in:
- lib/rhoconnect/test_methods.rb,
lib/rhoconnect/source_adapter.rb
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(source, credential = nil) ⇒ SourceAdapter
Returns a new instance of SourceAdapter.
18
19
20
|
# File 'lib/rhoconnect/source_adapter.rb', line 18
def initialize(source,credential=nil)
@source = source
end
|
Instance Attribute Details
#result ⇒ Object
Returns the value of attribute result.
3
4
5
|
# File 'lib/rhoconnect/test_methods.rb', line 3
def result
@result
end
|
#session ⇒ Object
Returns the value of attribute session.
16
17
18
|
# File 'lib/rhoconnect/source_adapter.rb', line 16
def session
@session
end
|
Class Method Details
.create(source, credential = nil) ⇒ Object
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
# File 'lib/rhoconnect/source_adapter.rb', line 22
def self.create(source,credential=nil)
adapter=nil
if source
begin
if source.name
source.name = source.name.dup if source.name.frozen?
source.name.strip!
end
if Rhoconnect.predefined_sources.has_key?(source.name)
adapter=(Object.const_get(source.name)).new(source)
elsif Object.const_defined?(source.name) && Object.const_get(source.name).to_s.split("::").first != 'Rhoconnect'
require under_score(source.name)
adapter=(Object.const_get(source.name)).new(source)
else
adapter=DynamicAdapter.new(source)
end
rescue ArgumentError => e
adapter=(Object.const_get(source.name)).new(source,credential)
log "WARNING: credential parameter in `initialize` method is deprecated and removed in version >= 2.2.0."
rescue Exception => e
log "Failure to create adapter from class #{source.name}: #{e.inspect.to_s}"
raise e
end
end
adapter
end
|
Instance Method Details
#ask(params = nil) ⇒ Object
113
|
# File 'lib/rhoconnect/source_adapter.rb', line 113
def ask(params=nil); end
|
#create(create_hash) ⇒ Object
107
|
# File 'lib/rhoconnect/source_adapter.rb', line 107
def create(create_hash); end
|
#delete(delete_hash) ⇒ Object
111
|
# File 'lib/rhoconnect/source_adapter.rb', line 111
def delete(delete_hash); end
|
#do_query(params = nil) ⇒ Object
79
80
81
82
83
84
85
86
87
88
89
|
# File 'lib/rhoconnect/source_adapter.rb', line 79
def do_query(params=nil)
@tmp_docname = @source.docname(:md) + get_random_uuid
@stash_size = 0
params ? self.query(params) : self.query
if @source.is_pass_through?
@result
else
self.sync
true
end
end
|
#expire_bulk_data(partition = :user) ⇒ Object
#login ⇒ Object
54
|
# File 'lib/rhoconnect/source_adapter.rb', line 54
def login; end
|
#logoff ⇒ Object
115
|
# File 'lib/rhoconnect/source_adapter.rb', line 115
def logoff; end
|
#query(params = nil) ⇒ Object
56
|
# File 'lib/rhoconnect/source_adapter.rb', line 56
def query(params=nil); end
|
#save(docname) ⇒ Object
117
118
119
120
121
122
123
124
|
# File 'lib/rhoconnect/source_adapter.rb', line 117
def save(docname)
return if @result.nil?
if @result.empty?
Store.flash_data(docname)
else
Store.put_data(docname,@result)
end
end
|
#search(params = nil) ⇒ Object
58
|
# File 'lib/rhoconnect/source_adapter.rb', line 58
def search(params=nil); end
|
#stash_result ⇒ Object
91
92
93
94
95
96
|
# File 'lib/rhoconnect/source_adapter.rb', line 91
def stash_result
return if @result.nil?
Store.put_data(@tmp_docname,@result,true)
@stash_size += @result.size
@result = nil
end
|
#sync ⇒ Object
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
# File 'lib/rhoconnect/source_adapter.rb', line 60
def sync
if @result and @result.empty?
@source.lock(:md) do |s|
s.flash_data(:md)
s.put_value(:md_size,0)
end
else
if @result
Store.put_data(@tmp_docname,@result)
@stash_size += @result.size
end
@source.lock(:md) do |s|
s.flash_data(:md)
Store.rename(@tmp_docname,s.docname(:md))
s.put_value(:md_size,@stash_size)
end
end
end
|
#update(update_hash) ⇒ Object
109
|
# File 'lib/rhoconnect/source_adapter.rb', line 109
def update(update_hash); end
|
#validate(operation, operations_hashes, client_ids) ⇒ Object
do pre-processing before CUD operation
103
104
105
|
# File 'lib/rhoconnect/source_adapter.rb', line 103
def validate(operation,operations_hashes,client_ids)
{}
end
|