Class: Payload::Session
- Inherits:
-
Object
- Object
- Payload::Session
- Defined in:
- lib/payload/arm/session.rb
Instance Attribute Summary collapse
-
#api_key ⇒ Object
Returns the value of attribute api_key.
-
#api_url ⇒ Object
Returns the value of attribute api_url.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #_get_request(cls = nil) ⇒ Object
- #create(objects) ⇒ Object
- #delete(objects) ⇒ Object
-
#initialize(api_key, api_url = nil) ⇒ Session
constructor
A new instance of Session.
- #query(cls) ⇒ Object
- #to_s ⇒ Object
- #update(objects) ⇒ Object
Constructor Details
#initialize(api_key, api_url = nil) ⇒ Session
Returns a new instance of Session.
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/payload/arm/session.rb', line 9 def initialize(api_key, api_url=nil) @api_key = api_key @api_url = api_url || Payload.URL Payload.constants.each do |c| val = Payload.const_get(c) if val.is_a?(Class) && val < Payload::ARMObject define_singleton_method(c) { Payload::ARMObjectWrapper.new(val, self) } end end end |
Instance Attribute Details
#api_key ⇒ Object
Returns the value of attribute api_key.
7 8 9 |
# File 'lib/payload/arm/session.rb', line 7 def api_key @api_key end |
#api_url ⇒ Object
Returns the value of attribute api_url.
7 8 9 |
# File 'lib/payload/arm/session.rb', line 7 def api_url @api_url end |
Instance Method Details
#==(other) ⇒ Object
41 42 43 44 45 46 47 |
# File 'lib/payload/arm/session.rb', line 41 def ==(other) return false unless other.is_a?(Session) # Compare the attributes for equality api_key == other.api_key && api_url == other.api_url end |
#_get_request(cls = nil) ⇒ Object
21 22 23 |
# File 'lib/payload/arm/session.rb', line 21 def _get_request(cls = nil) return Payload::ARMRequest.new(cls, self) end |
#create(objects) ⇒ Object
29 30 31 |
# File 'lib/payload/arm/session.rb', line 29 def create(objects) return self._get_request().create(objects) end |
#delete(objects) ⇒ Object
37 38 39 |
# File 'lib/payload/arm/session.rb', line 37 def delete(objects) return self._get_request().delete_all(objects) end |
#query(cls) ⇒ Object
25 26 27 |
# File 'lib/payload/arm/session.rb', line 25 def query(cls) return self._get_request(cls) end |
#to_s ⇒ Object
49 50 51 |
# File 'lib/payload/arm/session.rb', line 49 def to_s "#{api_key} @ #{api_url}" end |
#update(objects) ⇒ Object
33 34 35 |
# File 'lib/payload/arm/session.rb', line 33 def update(objects) return self._get_request().update_all(objects) end |