Class: Delighted::Resource
- Inherits:
-
Object
- Object
- Delighted::Resource
- Defined in:
- lib/delighted/resource.rb
Direct Known Subclasses
Bounce, Metrics, Person, SurveyRequest, SurveyResponse, Unsubscribe
Class Attribute Summary collapse
- .expandable_attributes ⇒ Object
-
.path ⇒ Object
Returns the value of attribute path.
-
.singleton_resource ⇒ Object
writeonly
Sets the attribute singleton_resource.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(attributes = {}) ⇒ Resource
constructor
A new instance of Resource.
-
#to_hash ⇒ Object
(also: #to_h)
Attributes used for serialization.
Constructor Details
#initialize(attributes = {}) ⇒ Resource
20 21 22 23 24 |
# File 'lib/delighted/resource.rb', line 20 def initialize(attributes = {}) @id = attributes[:id] define_id_reader if @id build_from_attributes(attributes) end |
Class Attribute Details
.expandable_attributes ⇒ Object
7 8 9 |
# File 'lib/delighted/resource.rb', line 7 def ||= {} end |
.path ⇒ Object
Returns the value of attribute path.
4 5 6 |
# File 'lib/delighted/resource.rb', line 4 def path @path end |
.singleton_resource=(value) ⇒ Object (writeonly)
Sets the attribute singleton_resource
5 6 7 |
# File 'lib/delighted/resource.rb', line 5 def singleton_resource=(value) @singleton_resource = value end |
Class Method Details
.singleton_resource? ⇒ Boolean
11 12 13 |
# File 'lib/delighted/resource.rb', line 11 def singleton_resource? !!@singleton_resource end |
Instance Method Details
#to_hash ⇒ Object Also known as: to_h
Attributes used for serialization
27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/delighted/resource.rb', line 27 def to_hash serialized_attributes = attributes.dup self.class..each_pair.select do |attribute_name, | if === attributes[attribute_name] serialized_attributes[attribute_name] = serialized_attributes[attribute_name].id end end serialized_attributes end |