Class: Diecut::PluginDescription::Option
- Inherits:
-
Object
- Object
- Diecut::PluginDescription::Option
- Defined in:
- lib/diecut/plugin-description/option.rb
Instance Attribute Summary collapse
-
#context_path ⇒ Object
readonly
Returns the value of attribute context_path.
-
#default_value ⇒ Object
readonly
Returns the value of attribute default_value.
-
#description(desc = NO_VALUE) ⇒ Object
readonly
A description for the option in the user interface.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#default(value) ⇒ Object
Gives the option a default value (and therefore makes it optional for the user to provide).
-
#goes_to(*context_path) ⇒ Object
Defines the templating context path this value should be copied to.
- #has_context_path? ⇒ Boolean
- #has_default? ⇒ Boolean
-
#initialize(name) ⇒ Option
constructor
A new instance of Option.
Constructor Details
Instance Attribute Details
#context_path ⇒ Object (readonly)
Returns the value of attribute context_path.
8 9 10 |
# File 'lib/diecut/plugin-description/option.rb', line 8 def context_path @context_path end |
#default_value ⇒ Object (readonly)
Returns the value of attribute default_value.
8 9 10 |
# File 'lib/diecut/plugin-description/option.rb', line 8 def default_value @default_value end |
#description(desc = NO_VALUE) ⇒ Object (readonly)
A description for the option in the user interface.
21 22 23 |
# File 'lib/diecut/plugin-description/option.rb', line 21 def description @description end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
8 9 10 |
# File 'lib/diecut/plugin-description/option.rb', line 8 def name @name end |
Instance Method Details
#default(value) ⇒ Object
Gives the option a default value (and therefore makes it optional for the user to provide)
58 59 60 |
# File 'lib/diecut/plugin-description/option.rb', line 58 def default(value) @default_value = value end |
#goes_to(*context_path) ⇒ Object
Defines the templating context path this value should be copied to.
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/diecut/plugin-description/option.rb', line 37 def goes_to(*context_path) if context_path.length == 1 context_path = case context_path.first when Array context_path.first when /.+\..+/ # has an embedded . context_path.first.split('.') else context_path end end @context_path = context_path end |
#has_context_path? ⇒ Boolean
14 15 16 |
# File 'lib/diecut/plugin-description/option.rb', line 14 def has_context_path? !context_path.nil? end |
#has_default? ⇒ Boolean
10 11 12 |
# File 'lib/diecut/plugin-description/option.rb', line 10 def has_default? default_value != NO_VALUE end |