Sha256: a2f55246b2063ca9d3a225ff0839380e6901503d36cda249cc4ec4161ba11474
Contents?: true
Size: 792 Bytes
Versions: 13
Compression:
Stored size: 792 Bytes
Contents
# Allows to check the the view type by using `view.index?` or `view.edit?` etc... # It also allows to check if the view is a form or a display view by using `view.form?` or `view.display?` module Avo class ViewInquirer < ActiveSupport::StringInquirer DISPLAY_VIEWS = %w[index show] FORM_VIEWS = %w[new edit] def initialize(view) super(view.to_s) @display = in? DISPLAY_VIEWS @form = in? FORM_VIEWS end def display? @display end def form? @form end # To avoid breaking changes we allow the comparison with symbols def ==(other) if other.is_a? Symbol to_sym == other else super(other) end end def in?(another_object) super another_object.map(&:to_s) end end end
Version data entries
13 entries across 13 versions & 1 rubygems