Class: Avo::ViewInquirer

Inherits:
ActiveSupport::StringInquirer
  • Object
show all
Defined in:
lib/avo/view_inquirer.rb

Instance Method Summary collapse

Constructor Details

#initialize(view) ⇒ ViewInquirer

Returns a new instance of ViewInquirer.



5
6
7
8
9
10
# File 'lib/avo/view_inquirer.rb', line 5

def initialize(view)
  super(view.to_s)

  @display = in? %w[index show]
  @form = in? %w[new edit]
end

Instance Method Details

#==(other) ⇒ Object

To avoid breaking changes we allow the comparison with symbols



21
22
23
24
25
26
27
# File 'lib/avo/view_inquirer.rb', line 21

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

#display?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/avo/view_inquirer.rb', line 12

def display?
  @display
end

#form?Boolean

Returns:

  • (Boolean)


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

def form?
  @form
end

#in?(another_object) ⇒ Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/avo/view_inquirer.rb', line 29

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