Class: SK::SDK::Base
- Inherits:
-
ActiveResource::Base
- Object
- ActiveResource::Base
- SK::SDK::Base
- Defined in:
- lib/sk_sdk/base.rb
Defined Under Namespace
Classes: SkCollection
Class Method Summary collapse
-
.headers ⇒ Object
If headers are not defined in a given subclass, then obtain headers from the superclass.
-
.set_connection(opts) ⇒ Object
Define the connection to be used when talking to a salesking server.
Instance Method Summary collapse
-
#initialize(attributes = {}) ⇒ Base
constructor
A new instance of Base.
- #save ⇒ Object
Methods inherited from ActiveResource::Base
#load_attributes_from_response
Constructor Details
#initialize(attributes = {}) ⇒ Base
Returns a new instance of Base.
21 22 23 24 |
# File 'lib/sk_sdk/base.rb', line 21 def initialize(attributes = {}, *args) attr = attributes[self.class.element_name] || attributes super(attr, *args) end |
Class Method Details
.headers ⇒ Object
If headers are not defined in a given subclass, then obtain headers from the superclass.
55 56 57 58 59 60 61 62 63 |
# File 'lib/sk_sdk/base.rb', line 55 def self.headers if defined?(@headers) @headers elsif superclass != Object && superclass.headers superclass.headers else @headers ||= {} end end |
.set_connection(opts) ⇒ Object
Define the connection to be used when talking to a salesking server
@param opts
42 43 44 45 46 47 48 49 50 51 |
# File 'lib/sk_sdk/base.rb', line 42 def self.set_connection(opts) self.site = site_api_url(opts[:site]) self.format = :json if opts[:token] #oAuth access token in header self.headers['Authorization'] = "Bearer #{opts[:token]}" else self.user = opts[:user] self.password = opts[:password] end end |
Instance Method Details
#save ⇒ Object
32 |
# File 'lib/sk_sdk/base.rb', line 32 def save; save_with_validation; end |