Class: Nucleon::Plugin::Action::Option
- Inherits:
-
Object
- Object
- Nucleon::Plugin::Action::Option
- Defined in:
- lib/core/plugin/action.rb
Overview
Default option interface
Instance Attribute Summary collapse
-
#default ⇒ Object
Returns the value of attribute default.
-
#locale ⇒ Object
Returns the value of attribute locale.
-
#name ⇒ Object
readonly
—.
-
#provider ⇒ Object
readonly
—.
-
#type ⇒ Object
readonly
—.
-
#validator ⇒ Object
Returns the value of attribute validator.
Instance Method Summary collapse
-
#initialize(namespace, provider, name, type, default, locale = nil, &validator) ⇒ Option
constructor
A new instance of Option.
-
#validate(value, *args) ⇒ Object
—.
Constructor Details
#initialize(namespace, provider, name, type, default, locale = nil, &validator) ⇒ Option
Returns a new instance of Option.
55 56 57 58 59 60 61 62 |
# File 'lib/core/plugin/action.rb', line 55 def initialize(namespace, provider, name, type, default, locale = nil, &validator) @provider = provider @name = name @type = type @default = default @locale = locale.nil? ? "#{namespace}.action.#{provider.to_s.gsub('_', '.')}.options.#{name}" : locale @validator = validator if validator end |
Instance Attribute Details
#default ⇒ Object
Returns the value of attribute default.
67 68 69 |
# File 'lib/core/plugin/action.rb', line 67 def default @default end |
#locale ⇒ Object
Returns the value of attribute locale.
67 68 69 |
# File 'lib/core/plugin/action.rb', line 67 def locale @locale end |
#name ⇒ Object (readonly)
66 67 68 |
# File 'lib/core/plugin/action.rb', line 66 def name @name end |
#provider ⇒ Object (readonly)
66 67 68 |
# File 'lib/core/plugin/action.rb', line 66 def provider @provider end |
#type ⇒ Object (readonly)
66 67 68 |
# File 'lib/core/plugin/action.rb', line 66 def type @type end |
#validator ⇒ Object
Returns the value of attribute validator.
67 68 69 |
# File 'lib/core/plugin/action.rb', line 67 def validator @validator end |
Instance Method Details
#validate(value, *args) ⇒ Object
71 72 73 74 75 76 77 |
# File 'lib/core/plugin/action.rb', line 71 def validate(value, *args) success = true if @validator success = @validator.call(value, *args) end success end |