class Diecut::PluginDescription::Option
Attributes
context_path[R]
default_value[R]
description[R]
name[R]
Public Class Methods
new(name)
click to toggle source
# File lib/diecut/plugin-description/option.rb, line 4 def initialize(name) @name = name @default_value = NO_VALUE end
Public Instance Methods
default(value)
click to toggle source
Gives the option a default value (and therefore makes it optional for the user to provide)
@param value
The default value
# File lib/diecut/plugin-description/option.rb, line 58 def default(value) @default_value = value end
goes_to(*context_path)
click to toggle source
Defines the templating context path this value should be copied to. @param context_path
[Array,String]
The path into the context to set from this option's value.
@example Three equivalent calls
option.goes_to("deeply.nested.field") option.goes_to(%w{deeply nested field}) option.goes_to("deeply", "nested", "field")
# 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?()
click to toggle source
# File lib/diecut/plugin-description/option.rb, line 14 def has_context_path? !context_path.nil? end
has_default?()
click to toggle source
# File lib/diecut/plugin-description/option.rb, line 10 def has_default? default_value != NO_VALUE end