Class: Representors::Serialization::HaleSerializer
- Inherits:
-
HalSerializer
- Object
- Representors::SerializationBase
- Representors::SerializerBase
- HalSerializer
- Representors::Serialization::HaleSerializer
- Defined in:
- lib/representors/serialization/hale_serializer.rb
Constant Summary collapse
- SEMANTIC_TYPES =
{ select: "text", #No way in Crichton to distinguish [Int] and [String] search:"text", text: "text", boolean: "bool", #a Server should accept ?cat&dog or ?cat=cat&dog=dog number: "number", email: "text", tel: "text", datetime: "text", time: "text", date: "text", month: "text", week: "text", object: "object", :"datetime-local" => "text" }
Constants inherited from HalSerializer
Representors::Serialization::HalSerializer::EMBEDDED_KEY, Representors::Serialization::HalSerializer::LINKS_KEY, Representors::Serialization::HalSerializer::LINKS_ONLY_OPTION
Instance Attribute Summary
Attributes inherited from Representors::SerializationBase
Instance Method Summary collapse
-
#to_hash(options = {}) ⇒ Object
This is public and returning a hash to be able to implement embedded resources serialization TODO: make this private and merge with to_media_type The name is quite misleading,.
-
#to_media_type(options = {}) ⇒ Object
This is the main entry of this class.
Methods inherited from Representors::SerializerBase
Methods inherited from Representors::SerializationBase
Methods included from RepresentorSupport::Utilities
#deep_dup, #dup_or_self, #map_or_apply, #symbolize_keys
Constructor Details
This class inherits a constructor from Representors::SerializerBase
Instance Method Details
#to_hash(options = {}) ⇒ Object
This is public and returning a hash to be able to implement embedded resources serialization TODO: make this private and merge with to_media_type The name is quite misleading,
29 30 31 32 33 34 |
# File 'lib/representors/serialization/hale_serializer.rb', line 29 def to_hash( ={}) base_hash, links, = common_serialization(@target) = get_data_lists(@target) base_hash.merge!().merge!(links).merge!(.()) base_hash end |
#to_media_type(options = {}) ⇒ Object
This is the main entry of this class. It returns a serialization of the data in a given media type.
39 40 41 |
# File 'lib/representors/serialization/hale_serializer.rb', line 39 def to_media_type( = {}) to_hash().to_json end |