Class: Nucleon::Plugin::Action::Option

Inherits:
Object
  • Object
show all
Defined in:
lib/core/plugin/action.rb

Overview


Default option interface

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#defaultObject

Returns the value of attribute default.



67
68
69
# File 'lib/core/plugin/action.rb', line 67

def default
  @default
end

#localeObject

Returns the value of attribute locale.



67
68
69
# File 'lib/core/plugin/action.rb', line 67

def locale
  @locale
end

#nameObject (readonly)




66
67
68
# File 'lib/core/plugin/action.rb', line 66

def name
  @name
end

#providerObject (readonly)




66
67
68
# File 'lib/core/plugin/action.rb', line 66

def provider
  @provider
end

#typeObject (readonly)




66
67
68
# File 'lib/core/plugin/action.rb', line 66

def type
  @type
end

#validatorObject

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