Class: RestModel::Property
- Defined in:
- lib/rest_model/key/property.rb,
lib/rest_model/key/property/sender.rb,
lib/rest_model/key/property/builder.rb,
lib/rest_model/key/property/response.rb,
lib/rest_model/key/property/retriever.rb
Defined Under Namespace
Modules: Builder, Response, Retriever, Sender
Instance Attribute Summary collapse
-
#serializer ⇒ Object
Returns the value of attribute serializer.
-
#translation ⇒ Object
Returns the value of attribute translation.
Attributes inherited from Key
#model, #name, #options, #summarize
Instance Method Summary collapse
- #from_hash(value, resource = nil) ⇒ Object
-
#initialize(name, options = {}) ⇒ Property
constructor
A new instance of Property.
Methods included from Response
#build_links, #resource, #resource_keys, #summarize?
Methods included from Retriever
Methods included from Sender
Methods inherited from Key
#convert_input_keys, #present?, #root_path?, #source_path, #visible?
Constructor Details
#initialize(name, options = {}) ⇒ Property
Returns a new instance of Property.
12 13 14 15 16 |
# File 'lib/rest_model/key/property.rb', line 12 def initialize(name, = {}) super @serializer = .fetch(:type, Serialization::String) @translation = Source::Translation.new() end |
Instance Attribute Details
#serializer ⇒ Object
Returns the value of attribute serializer.
10 11 12 |
# File 'lib/rest_model/key/property.rb', line 10 def serializer @serializer end |
#translation ⇒ Object
Returns the value of attribute translation.
10 11 12 |
# File 'lib/rest_model/key/property.rb', line 10 def translation @translation end |
Instance Method Details
#from_hash(value, resource = nil) ⇒ Object
18 19 20 21 22 |
# File 'lib/rest_model/key/property.rb', line 18 def from_hash(value, resource = nil) serializer == Serialization::String ? value : serializer.serialize(value) rescue value end |