Class: Sapling::Base
- Inherits:
-
Object
- Object
- Sapling::Base
- Defined in:
- lib/sapling/base.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#controller ⇒ Object
Returns the value of attribute controller.
Instance Method Summary collapse
-
#active?(feature, options = {}) ⇒ Boolean
see Sapling::API::Client.
-
#active_features(options = {}) ⇒ Object
returns a list of features enabled for a user see Sapling::API::Client.
-
#css_class(feature) ⇒ Object
Use these classes on the container elements of your features.
- #css_class_prefix ⇒ Object
-
#css_toggle_class(feature, on) ⇒ Object
Put these on the html element to turn on/off features.
- #features ⇒ Object
-
#initialize(controller = nil) ⇒ Base
constructor
A new instance of Base.
- #js_generator ⇒ Object
Constructor Details
#initialize(controller = nil) ⇒ Base
Returns a new instance of Base.
5 6 7 |
# File 'lib/sapling/base.rb', line 5 def initialize(controller=nil) @controller = controller end |
Instance Attribute Details
#controller ⇒ Object
Returns the value of attribute controller.
3 4 5 |
# File 'lib/sapling/base.rb', line 3 def controller @controller end |
Instance Method Details
#active?(feature, options = {}) ⇒ Boolean
see Sapling::API::Client
26 27 28 29 |
# File 'lib/sapling/base.rb', line 26 def active?(feature, ={}) = Util. , controller active_internal(feature,) end |
#active_features(options = {}) ⇒ Object
returns a list of features enabled for a user see Sapling::API::Client
33 34 35 36 37 38 |
# File 'lib/sapling/base.rb', line 33 def active_features(={}) = Util. , controller ret={} features.each {|feature_name,feature| ret[feature_name]=feature if active_internal(feature_name,)} ret end |
#css_class(feature) ⇒ Object
Use these classes on the container elements of your features
49 50 51 |
# File 'lib/sapling/base.rb', line 49 def css_class(feature) "#{css_class_prefix}_#{feature.to_s}" end |
#css_class_prefix ⇒ Object
44 45 46 |
# File 'lib/sapling/base.rb', line 44 def css_class_prefix "sapling_feature" end |
#css_toggle_class(feature, on) ⇒ Object
Put these on the html element to turn on/off features
54 55 56 |
# File 'lib/sapling/base.rb', line 54 def css_toggle_class(feature, on) "#{css_class(feature)}_#{on ? 'on' : 'off'}" end |
#features ⇒ Object
9 |
# File 'lib/sapling/base.rb', line 9 def features; @features||={}; end |
#js_generator ⇒ Object
40 41 42 |
# File 'lib/sapling/base.rb', line 40 def js_generator @js_generator ||= JavascriptGenerator.new(self) end |