Class: Avo::ViewInquirer

Inherits:
ActiveSupport::StringInquirer
  • Object
show all
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

Constructor Details

#initialize(view) ⇒ ViewInquirer

Returns a new instance of ViewInquirer.



8
9
10
11
12
13
# File 'lib/avo/view_inquirer.rb', line 8

def initialize(view)
  super(view.to_s)

  @display = in? DISPLAY_VIEWS
  @form = in? FORM_VIEWS
end

Instance Method Details

#==(other) ⇒ Object

To avoid breaking changes we allow the comparison with symbols



24
25
26
27
28
29
30
# File 'lib/avo/view_inquirer.rb', line 24

def ==(other)
  if other.is_a? Symbol
    to_sym == other
  else
    super(other)
  end
end

#display?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/avo/view_inquirer.rb', line 15

def display?
  @display
end

#form?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/avo/view_inquirer.rb', line 19

def form?
  @form
end

#in?(another_object) ⇒ Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/avo/view_inquirer.rb', line 32

def in?(another_object)
  super(another_object.map(&:to_s))
end