Class: RailsOmnibar::Item::Base
- Inherits:
-
Object
- Object
- RailsOmnibar::Item::Base
- Defined in:
- lib/rails_omnibar/item/base.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#modal_html ⇒ Object
readonly
Returns the value of attribute modal_html.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
- #as_json ⇒ Object
-
#initialize(title:, url: nil, modal_html: nil, type: :default) ⇒ Base
constructor
A new instance of Base.
Constructor Details
#initialize(title:, url: nil, modal_html: nil, type: :default) ⇒ Base
Returns a new instance of Base.
6 7 8 9 10 11 12 13 14 |
# File 'lib/rails_omnibar/item/base.rb', line 6 def initialize(title:, url: nil, modal_html: nil, type: :default) title.class.in?([String, Symbol]) && title.present? || raise(ArgumentError, 'title: must be a String') url.present? && modal_html.present? && raise(ArgumentError, 'use EITHER url: OR modal_html:') @title = title @url = url @modal_html = modal_html @type = type end |
Instance Attribute Details
#modal_html ⇒ Object (readonly)
Returns the value of attribute modal_html.
4 5 6 |
# File 'lib/rails_omnibar/item/base.rb', line 4 def modal_html @modal_html end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
4 5 6 |
# File 'lib/rails_omnibar/item/base.rb', line 4 def title @title end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
4 5 6 |
# File 'lib/rails_omnibar/item/base.rb', line 4 def type @type end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
4 5 6 |
# File 'lib/rails_omnibar/item/base.rb', line 4 def url @url end |
Instance Method Details
#as_json ⇒ Object
16 17 18 |
# File 'lib/rails_omnibar/item/base.rb', line 16 def as_json(*) { title: title, url: url, modalHTML: modal_html, type: type } end |