Module: CiscoSpark::Model
- Included in:
- Membership, Message, Person, Room, Team, TeamMembership, Webhook
- Defined in:
- lib/cisco_spark/model.rb
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
- #destroy ⇒ Object
- #fetch ⇒ Object
-
#initialize(attributes = {}) ⇒ Object
ClassMethods.
- #persist ⇒ Object
- #to_h ⇒ Object
Class Method Details
.included(base) ⇒ Object
7 8 9 |
# File 'lib/cisco_spark/model.rb', line 7 def self.included(base) base.extend(ClassMethods) end |
Instance Method Details
#destroy ⇒ Object
87 88 89 |
# File 'lib/cisco_spark/model.rb', line 87 def destroy self.class.destroy(id) end |
#fetch ⇒ Object
78 79 80 81 |
# File 'lib/cisco_spark/model.rb', line 78 def fetch merge_attributes(self.class.fetch(id)) self end |
#initialize(attributes = {}) ⇒ Object
ClassMethods
74 75 76 |
# File 'lib/cisco_spark/model.rb', line 74 def initialize(attributes={}) assign_attributes(attributes) end |
#persist ⇒ Object
83 84 85 |
# File 'lib/cisco_spark/model.rb', line 83 def persist id ? update : create end |
#to_h ⇒ Object
91 92 93 94 95 |
# File 'lib/cisco_spark/model.rb', line 91 def to_h self.class.attributes.keys.each_with_object({}) { |name, hash| hash[name] = send(name) } end |