Class: Karmacrm::Base
- Inherits:
-
ActiveResource::Base
- Object
- ActiveResource::Base
- Karmacrm::Base
show all
- Defined in:
- lib/karmacrm/base.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.api_key ⇒ Object
11
12
13
|
# File 'lib/karmacrm/base.rb', line 11
def api_key
@@api_key ||= ""
end
|
.api_key=(api_key) ⇒ Object
7
8
9
|
# File 'lib/karmacrm/base.rb', line 7
def api_key=(api_key)
@@api_key = api_key
end
|
.api_version ⇒ Object
15
16
17
|
# File 'lib/karmacrm/base.rb', line 15
def api_version
@@api_version ||= "1"
end
|
.config {|_self| ... } ⇒ Object
29
30
31
|
# File 'lib/karmacrm/base.rb', line 29
def config
yield self
end
|
.find(*args) ⇒ Object
40
41
42
43
44
45
46
|
# File 'lib/karmacrm/base.rb', line 40
def find(*args)
scope = args.slice!(0)
options = args.slice!(0) || {}
options.merge!({:params => {:api_key => api_key}})
items = super(scope, options)
end
|
19
20
21
|
# File 'lib/karmacrm/base.rb', line 19
def format
@@format ||= ActiveResource::Formats::JsonFormat
end
|
.instantiate_collection(collection, prefix_options = {}) ⇒ Object
35
36
37
38
|
# File 'lib/karmacrm/base.rb', line 35
def instantiate_collection(collection, prefix_options = {})
collection = collection[collection_name] if collection.is_a? Hash
instantiate_collection_orig(collection, prefix_options)
end
|
.instantiate_collection_orig ⇒ Object
33
|
# File 'lib/karmacrm/base.rb', line 33
alias :instantiate_collection_orig :instantiate_collection
|
.site=(site_url) ⇒ Object
23
24
25
26
27
|
# File 'lib/karmacrm/base.rb', line 23
def site=(site_url)
self.prefix = "/api/v#{api_version}/"
self.include_root_in_json = true
super(site_url)
end
|
Instance Method Details
#save ⇒ Object
49
50
51
52
|
# File 'lib/karmacrm/base.rb', line 49
def save
prefix_options[:api_key] = self.class.api_key
super
end
|