Class: Gretel::JSONLD::Breadcrumb::ListItem
- Inherits:
-
Object
- Object
- Gretel::JSONLD::Breadcrumb::ListItem
- Defined in:
- lib/gretel/jsonld/breadcrumb/list_item.rb
Instance Method Summary collapse
-
#as_json(options = nil) ⇒ Object
NOTE: Override #as_json to cope with Rails 4.0 or former.
-
#initialize(id:, name:, position:) ⇒ ListItem
constructor
A new instance of ListItem.
- #to_json(*args) ⇒ Object
Constructor Details
#initialize(id:, name:, position:) ⇒ ListItem
Returns a new instance of ListItem.
11 12 13 14 15 |
# File 'lib/gretel/jsonld/breadcrumb/list_item.rb', line 11 def initialize(id:, name:, position:) @id = id @name = name @position = position end |
Instance Method Details
#as_json(options = nil) ⇒ Object
NOTE: Override #as_json to cope with Rails 4.0 or former
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/gretel/jsonld/breadcrumb/list_item.rb', line 18 def as_json( = nil) { "@type": "ListItem", position: @position, item: { "@id": @id, name: @name, } }.as_json() end |
#to_json(*args) ⇒ Object
29 30 31 |
# File 'lib/gretel/jsonld/breadcrumb/list_item.rb', line 29 def to_json(*args) as_json.to_json(*args) end |