Class: Hypermicrodata::Serializer::Uber
- Defined in:
- lib/hypermicrodata/serializer/uber.rb
Constant Summary collapse
- ACTION_MAPPINGS =
{ 'GET' => 'read', 'POST' => 'append', 'PUT' => 'replace', 'DELETE' => 'remove', 'PATCH' => 'partial' }.freeze
Instance Method Summary collapse
Methods inherited from Base
Constructor Details
This class inherits a constructor from Hypermicrodata::Serializer::Base
Instance Method Details
#serialize ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/hypermicrodata/serializer/uber.rb', line 12 def serialize items = @document.items if items.length == 1 root_data = item_to_nested_data(items.first) if @location root_data.rel = 'self' root_data.url = @location end root_data.add_link('profile', @profile_path) if @profile_path uber = Uberous::Uber.new([root_data]) else data_collection = @document.items.map do |item| item_to_nested_data(item).tap do |data| data.name = generate_short_name(item.type) if item.type end end uber = Uberous::Uber.new(data_collection) uber.add_link('self', @location) if @location uber.add_link('profile', @profile_path) if @profile_path end uber.to_hash end |