Class: BuildTool::Feature
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- BuildTool::Feature
- Defined in:
- lib/build-tool/model/feature.rb
Overview
A feature bundles modules and makes it possible to enable/disable them together.
Instance Attribute Summary collapse
-
#default_active ⇒ Object
The default state of the feature.
-
#description ⇒ Object
A short description for the feature.
-
#environments ⇒ Object
readonly
The environments associated with this feature.
-
#long_description ⇒ Object
A long description for the feature.
-
#modules ⇒ Object
readonly
The modules associated with this feature.
Instance Method Summary collapse
-
#active? ⇒ Boolean
Is the feature active?.
-
#active_char ⇒ Object
Return a character showing the features active state.
-
#default_active? ⇒ Boolean
Is the feature active by default?.
- #my_initialize ⇒ Object
-
#path ⇒ Object
Return a unique name for the feature.
- #to_s ⇒ Object
Instance Attribute Details
#default_active ⇒ Object
The default state of the feature
19 20 21 |
# File 'lib/build-tool/model/feature.rb', line 19 def default_active @default_active end |
#description ⇒ Object
A short description for the feature
13 14 15 |
# File 'lib/build-tool/model/feature.rb', line 13 def description @description end |
#environments ⇒ Object (readonly)
The environments associated with this feature
25 26 27 |
# File 'lib/build-tool/model/feature.rb', line 25 def environments @environments end |
#long_description ⇒ Object
A long description for the feature
16 17 18 |
# File 'lib/build-tool/model/feature.rb', line 16 def long_description @long_description end |
#modules ⇒ Object (readonly)
The modules associated with this feature
22 23 24 |
# File 'lib/build-tool/model/feature.rb', line 22 def modules @modules end |
Instance Method Details
#active? ⇒ Boolean
Is the feature active?
38 39 40 41 42 43 44 45 |
# File 'lib/build-tool/model/feature.rb', line 38 def active? state = active.nil? ? default_active : active if parent_id.nil? state else parent.active? && state end end |
#active_char ⇒ Object
Return a character showing the features active state.
48 49 50 51 52 53 54 |
# File 'lib/build-tool/model/feature.rb', line 48 def active_char if active? ANSI::Code.green { "A" } else "I" end end |
#default_active? ⇒ Boolean
Is the feature active by default?
57 58 59 |
# File 'lib/build-tool/model/feature.rb', line 57 def default_active? default_active end |
#my_initialize ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/build-tool/model/feature.rb', line 29 def my_initialize @description = nil @long_description = nil @modules = [] @environments = [] @default_active = true end |
#path ⇒ Object
Return a unique name for the feature.
The name is scoped with the parents name.
64 65 66 67 68 69 70 |
# File 'lib/build-tool/model/feature.rb', line 64 def path if parent.nil? name else "%s/%s" % [ parent.path, name ] end end |
#to_s ⇒ Object
72 73 74 |
# File 'lib/build-tool/model/feature.rb', line 72 def to_s "Feature #{name} ( #{self.active} / #{self.default_active} )" end |