class Compendium::Option
Attributes
choices[RW]
default[RW]
name[RW]
options[RW]
type[RW]
Public Class Methods
new(hash = {})
click to toggle source
# File lib/compendium/option.rb, line 13 def initialize(hash = {}) raise ArgumentError, "name must be provided" unless hash.key?(:name) @name = hash.delete(:name).to_sym @default = hash.delete(:default) @choices = hash.delete(:choices) self.type = hash.delete(:type) @options = hash.with_indifferent_access end
Public Instance Methods
method_missing(name, *args, &block)
click to toggle source
Calls superclass method
# File lib/compendium/option.rb, line 27 def method_missing(name, *args, &block) return options[name] if options.key?(name) return options.key?(name[0...-1]) if name.to_s.end_with?('?') super end
respond_to_missing?(name, include_private = false)
click to toggle source
Calls superclass method
# File lib/compendium/option.rb, line 33 def respond_to_missing?(name, include_private = false) return true if options.key?(name) super end
type=(type)
click to toggle source
# File lib/compendium/option.rb, line 23 def type=(type) @type = ActiveSupport::StringInquirer.new(type.to_s) end