Sha256: c0c5d3b38353f7db8e4c3483cf0c91561991263fe3e1f75295c5febbaab0f662
Contents?: true
Size: 729 Bytes
Versions: 1
Compression:
Stored size: 729 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 def initialize(view) super(view.to_s) @display = in? %w[index show] @form = in? %w[new edit] 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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
avo-3.0.1.beta20 | lib/avo/view_inquirer.rb |