Class: Sirportly::DataObject
- Inherits:
-
Object
- Object
- Sirportly::DataObject
- Defined in:
- lib/sirportly/data_object.rb
Direct Known Subclasses
ApiToken, Brand, CustomField, Customer, CustomerContactMethod, Department, EscalationPath, FacebookPage, Filter, KnowledgeBase, KnowledgeBasePage, Priority, SLA, Status, Team, Ticket, TicketUpdate, TwitterAccount, User
Class Attribute Summary collapse
-
.collection_path ⇒ Object
Returns the value of attribute collection_path.
-
.maps ⇒ Object
Returns the value of attribute maps.
-
.member ⇒ Object
Returns the value of attribute member.
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#client ⇒ Object
readonly
Returns the value of attribute client.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(client, attributes = {}) ⇒ DataObject
constructor
A new instance of DataObject.
- #inspect ⇒ Object
- #method_missing(name) ⇒ Object
Constructor Details
#initialize(client, attributes = {}) ⇒ DataObject
Returns a new instance of DataObject.
26 27 28 29 |
# File 'lib/sirportly/data_object.rb', line 26 def initialize(client, attributes = {}) @client = client set_attributes(attributes) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name) ⇒ Object
35 36 37 38 39 40 41 |
# File 'lib/sirportly/data_object.rb', line 35 def method_missing(name) if attributes.keys.include?(name.to_s) attributes[name.to_s] else super end end |
Class Attribute Details
.collection_path ⇒ Object
Returns the value of attribute collection_path.
5 6 7 |
# File 'lib/sirportly/data_object.rb', line 5 def collection_path @collection_path end |
.maps ⇒ Object
Returns the value of attribute maps.
7 8 9 |
# File 'lib/sirportly/data_object.rb', line 7 def maps @maps end |
.member ⇒ Object
Returns the value of attribute member.
6 7 8 |
# File 'lib/sirportly/data_object.rb', line 6 def member @member end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
23 24 25 |
# File 'lib/sirportly/data_object.rb', line 23 def attributes @attributes end |
#client ⇒ Object (readonly)
Returns the value of attribute client.
24 25 26 |
# File 'lib/sirportly/data_object.rb', line 24 def client @client end |
Class Method Details
.all(client, options = {}) ⇒ Object
9 10 11 12 13 |
# File 'lib/sirportly/data_object.rb', line 9 def all(client, = {}) raise Sirportly::Error, "This object does not support a full list" if collection_path.nil? result = client.request(collection_path, ) DataSet.new(client, result, self) end |
.find(client, query) ⇒ Object
15 16 17 18 19 |
# File 'lib/sirportly/data_object.rb', line 15 def find(client, query) raise Sirportly::Error, "This object does not support finding objects" unless member.is_a?(Hash) result = client.request(member[:path], {member[:param] => query}) self.new(client, result) end |
Instance Method Details
#inspect ⇒ Object
31 32 33 |
# File 'lib/sirportly/data_object.rb', line 31 def inspect "#<#{self.class.to_s} #{attributes.inspect}>" end |