Module: FeatureRich::ModelBehaviour::InstanceMethods

Defined in:
lib/feature-rich/model_behaviour.rb

Overview

ClassMethods

Instance Method Summary collapse

Instance Method Details

#featuresObject



17
18
19
# File 'lib/feature-rich/model_behaviour.rb', line 17

def features
  _feature.content
end

#features=(ary) ⇒ Object



21
22
23
# File 'lib/feature-rich/model_behaviour.rb', line 21

def features=(ary)
  _feature.modify(ary)
end

#has_feature?(feature, options = {}) ⇒ Boolean

Returns:

  • (Boolean)


25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/feature-rich/model_behaviour.rb', line 25

def has_feature?(feature, options = {})
  with_group(feature, options[:group]) do |f|
    case f
    when Symbol, String
      features.features.include?(f.to_sym)
    when GroupFeature
      f.disabled? || f.subset?(features.features) || features.group_features.include?(f.name)
    when FeatureHandler
      f.disabled? || features.features.include?(f.name)
    end
  end
end