Module: Intrinsic::Intrinsicism

Defined in:
lib/intrinsic/intrinsicism.rb,
lib/intrinsic/intrinsicism/coercion.rb,
lib/intrinsic/intrinsicism/validation.rb,
lib/intrinsic/intrinsicism/coercion/hash.rb,
lib/intrinsic/intrinsicism/coercion/proc.rb,
lib/intrinsic/intrinsicism/coercion/array.rb,
lib/intrinsic/intrinsicism/coercion/string.rb,
lib/intrinsic/intrinsicism/coercion/symbol.rb,
lib/intrinsic/intrinsicism/coercion/integer.rb

Defined Under Namespace

Modules: Coercion, Validation

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#defaultsObject (readonly)

Returns the value of attribute defaults.



7
8
9
# File 'lib/intrinsic/intrinsicism.rb', line 7

def defaults
  @defaults
end

#propertiesObject (readonly)

Returns the value of attribute properties.



7
8
9
# File 'lib/intrinsic/intrinsicism.rb', line 7

def properties
  @properties
end

Instance Method Details

#property(name, type = String, options = {}) ⇒ Object



9
10
11
12
13
14
15
16
# File 'lib/intrinsic/intrinsicism.rb', line 9

def property(name, type = String, options = {})
  @properties ||= []
  @defaults ||= {}
  check_types_for name, type, options
  define_method name, property_block(name, type)
  @properties << name
  @defaults[name.to_sym] = options[:default]
end