Class: Avo::ViewInquirer
- Inherits:
-
ActiveSupport::StringInquirer
- Object
- ActiveSupport::StringInquirer
- Avo::ViewInquirer
- Defined in:
- lib/avo/view_inquirer.rb
Constant Summary collapse
- DISPLAY_VIEWS =
%w[index show].freeze
- FORM_VIEWS =
%w[new edit create update].freeze
Instance Method Summary collapse
-
#==(other) ⇒ Object
To avoid breaking changes we allow the comparison with symbols.
- #display? ⇒ Boolean
- #form? ⇒ Boolean
- #in?(another_object) ⇒ Boolean
-
#initialize(view) ⇒ ViewInquirer
constructor
A new instance of ViewInquirer.
- #single? ⇒ Boolean
Constructor Details
#initialize(view) ⇒ ViewInquirer
Returns a new instance of ViewInquirer.
8 9 10 11 12 13 14 |
# File 'lib/avo/view_inquirer.rb', line 8 def initialize(view) super(view.to_s) @display = in? DISPLAY_VIEWS @form = in? FORM_VIEWS @single = in? [*FORM_VIEWS, :show].compact.uniq end |
Instance Method Details
#==(other) ⇒ Object
To avoid breaking changes we allow the comparison with symbols
29 30 31 32 33 34 35 |
# File 'lib/avo/view_inquirer.rb', line 29 def ==(other) if other.is_a? Symbol to_sym == other else super end end |
#display? ⇒ Boolean
16 17 18 |
# File 'lib/avo/view_inquirer.rb', line 16 def display? @display end |
#form? ⇒ Boolean
20 21 22 |
# File 'lib/avo/view_inquirer.rb', line 20 def form? @form end |
#in?(another_object) ⇒ Boolean
37 38 39 |
# File 'lib/avo/view_inquirer.rb', line 37 def in?(another_object) super(another_object.map(&:to_s)) end |
#single? ⇒ Boolean
24 25 26 |
# File 'lib/avo/view_inquirer.rb', line 24 def single? @single end |