Class: Hypermicrodata::Serializer::Base
- Inherits:
-
Object
- Object
- Hypermicrodata::Serializer::Base
- Defined in:
- lib/hypermicrodata/serializer/base.rb
Instance Method Summary collapse
-
#initialize(document, location = nil, profile_path = nil) ⇒ Base
constructor
A new instance of Base.
- #serialize ⇒ Object
- #to_json(options = {}) ⇒ Object
Constructor Details
#initialize(document, location = nil, profile_path = nil) ⇒ Base
Returns a new instance of Base.
4 5 6 7 8 |
# File 'lib/hypermicrodata/serializer/base.rb', line 4 def initialize(document, location = nil, profile_path = nil) @document = document @location = location @profile_path = profile_path end |
Instance Method Details
#serialize ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/hypermicrodata/serializer/base.rb', line 14 def serialize # return hash or array suitable for application/json if @document.items @document.items.map(&:to_hash) else [] end end |
#to_json(options = {}) ⇒ Object
10 11 12 |
# File 'lib/hypermicrodata/serializer/base.rb', line 10 def to_json( = {}) MultiJson.dump(serialize, ) end |