Module: Detour::Flaggable
- Defined in:
- lib/detour/flaggable.rb
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
- #detour_features ⇒ Object
-
#has_feature?(feature_name, &block) ⇒ Boolean
Returns whether or not the object has access to the given feature.
Instance Method Details
#detour_features ⇒ Object
44 45 46 |
# File 'lib/detour/flaggable.rb', line 44 def detour_features @detour_features ||= [] end |
#has_feature?(feature_name, &block) ⇒ Boolean
Returns whether or not the object has access to the given feature. If given a block, it will call the block if the user has access to the feature.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/detour/flaggable.rb', line 24 def has_feature?(feature_name, &block) if detour_features.include? feature_name.to_s match = true else feature = Detour::Feature.find_by_name(feature_name) return false unless feature opt_out = opt_out_flags.find_by_feature_id(feature.id) return false if opt_out match = feature.match? self if match detour_features << feature.name.to_s end end match end |