class Configurator::OptionValue
Public Class Methods
new(option)
click to toggle source
Calls superclass method
# File lib/configurator/delegated.rb, line 21 def initialize(option) @option = option case @option.type when :string then self.class.send(:define_method, :to_str) { self.to_s } unless defined? :to_str when :integer then self.class.send(:define_method, :to_int) { self.to_i } unless defined? :to_int end super(option.value) end
Public Instance Methods
cast()
click to toggle source
# File lib/configurator/delegated.rb, line 50 def cast; @option.caster.class.name.split('::').last.downcase.to_sym; end
default()
click to toggle source
# File lib/configurator/delegated.rb, line 52 def default; @option.default; end
empty?()
click to toggle source
# File lib/configurator/delegated.rb, line 58 def empty?; !option.value.nil? && @option.value.empty?; end
method_missing(method, *args, &block)
click to toggle source
Calls superclass method
# File lib/configurator/delegated.rb, line 34 def method_missing(method, *args, &block) begin super rescue NoMethodError begin raise NoMethodError, "undefined method '#{method}' for #{@option.type} option #{path_name}." rescue NoMethodError => e # hack to remove trace information for this file e.backtrace.collect!{ |line| line.include?(__FILE__) ? nil : line}.compact! raise end end end
name()
click to toggle source
# File lib/configurator/delegated.rb, line 48 def name; @option.name; end
nil?()
click to toggle source
# File lib/configurator/delegated.rb, line 59 def nil?; @option.value.nil?; end
optional?()
click to toggle source
# File lib/configurator/delegated.rb, line 62 def optional?; @option.optional?; end
parent()
click to toggle source
# File lib/configurator/delegated.rb, line 49 def parent; @option.parent; end
path_name()
click to toggle source
# File lib/configurator/delegated.rb, line 56 def path_name; @option.path_name; end
required?()
click to toggle source
# File lib/configurator/delegated.rb, line 61 def required?; @option.required?; end
root()
click to toggle source
# File lib/configurator/delegated.rb, line 55 def root; parent ? parent.root : nil; end
type()
click to toggle source
# File lib/configurator/delegated.rb, line 51 def type; @option.type; end
valid?()
click to toggle source
# File lib/configurator/delegated.rb, line 60 def valid?; @option.valid?; end
value()
click to toggle source
# File lib/configurator/delegated.rb, line 53 def value; self; end