Module: Domain::CoercionMethods

Included in:
Domain
Defined in:
lib/myrrha/ext/domain.rb

Instance Method Summary collapse

Instance Method Details

#coerce(arg) ⇒ Object Also known as: []



16
17
18
# File 'lib/myrrha/ext/domain.rb', line 16

def coerce(arg)
  coercions.coerce(arg, self)
end

#coercions(&bl) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
# File 'lib/myrrha/ext/domain.rb', line 4

def coercions(&bl)
  @coercions ||= ::Myrrha::Coercions.new{|c|
    c.main_target_domain = self
    c.error_handler = lambda{|v,t,c|
      raise c if TypeError===c
      domain_error!(v)
    }
  }
  @coercions.append(&bl) if bl
  @coercions
end