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
-
#icon ⇒ Object
readonly
Returns the value of attribute icon.
-
#if ⇒ Object
readonly
Returns the value of attribute if.
-
#modal_html ⇒ Object
readonly
Returns the value of attribute modal_html.
-
#suggested ⇒ Object
readonly
Returns the value of attribute suggested.
-
#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, icon: nil, modal_html: nil, suggested: false, type: :default, if: nil) ⇒ Base
constructor
A new instance of Base.
- #render?(context:, omnibar:) ⇒ Boolean
Constructor Details
#initialize(title:, url: nil, icon: nil, modal_html: nil, suggested: false, type: :default, if: nil) ⇒ Base
Returns a new instance of Base.
6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/rails_omnibar/item/base.rb', line 6 def initialize(title:, url: nil, icon: nil, modal_html: nil, suggested: false, type: :default, if: nil) url.present? && modal_html.present? && raise(ArgumentError, 'use EITHER url: OR modal_html:') @title = validate_title(title) @url = url @icon = validate_icon(icon) @modal_html = modal_html @suggested = !!suggested @type = type @if = .cast_to_condition(binding.local_variable_get(:if)) end |
Instance Attribute Details
#icon ⇒ Object (readonly)
Returns the value of attribute icon.
4 5 6 |
# File 'lib/rails_omnibar/item/base.rb', line 4 def icon @icon end |
#if ⇒ Object (readonly)
Returns the value of attribute if.
4 5 6 |
# File 'lib/rails_omnibar/item/base.rb', line 4 def if @if end |
#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 |
#suggested ⇒ Object (readonly)
Returns the value of attribute suggested.
4 5 6 |
# File 'lib/rails_omnibar/item/base.rb', line 4 def suggested @suggested 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
18 19 20 21 |
# File 'lib/rails_omnibar/item/base.rb', line 18 def as_json(*) @as_json ||= { title: title, url: url, icon: icon, modalHTML: modal_html, suggested: suggested, type: type } end |
#render?(context:, omnibar:) ⇒ Boolean
23 24 25 |
# File 'lib/rails_omnibar/item/base.rb', line 23 def render?(context:, omnibar:) .evaluate_condition(self.if, context: context, omnibar: ) end |