Class: Shrink::Wrap::Property::Coercion

Inherits:
Object
  • Object
show all
Defined in:
lib/shrink/wrap/property/coercion.rb,
lib/shrink/wrap/property/coercion/proc.rb,
lib/shrink/wrap/property/coercion/class.rb,
lib/shrink/wrap/property/coercion/enumerable.rb

Defined Under Namespace

Classes: Class, Enumerable, Proc

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value) ⇒ Coercion

Returns a new instance of Coercion.



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/shrink/wrap/property/coercion.rb', line 9

def initialize(value)
  case value
  when ::Class
    self.base = Coercion::Class.new(value)
  when ::Enumerable
    self.base = Coercion::Enumerable.new(value)
  when ::Proc
    self.base = Coercion::Proc.new(value)
  else
    fail!(value)
  end
end

Instance Attribute Details

#baseObject

Returns the value of attribute base.



7
8
9
# File 'lib/shrink/wrap/property/coercion.rb', line 7

def base
  @base
end

Instance Method Details

#coerce(data) ⇒ Object



22
23
24
# File 'lib/shrink/wrap/property/coercion.rb', line 22

def coerce(data)
  base.coerce(data)
end