Module: Domain::Factory

Included in:
Domain
Defined in:
lib/domain/factory.rb

Instance Method Summary collapse

Instance Method Details

#sbyc(super_domain = Object, &pred) ⇒ Class

Creates a domain through specialization by constraint

Parameters:

  • super_domain (Class) (defaults to: Object)

    the super_domain of the factored domain

  • pred (Proc)

    the domain predicate

Returns:

  • (Class)

    the created domain as a ruby Class



19
20
21
# File 'lib/domain/factory.rb', line 19

def sbyc(super_domain = Object, &pred)
  Class.new(super_domain){ extend SByC.new(super_domain, pred) }
end

#scalar(*component_names) ⇒ Class

Factors a scalar domain

Parameters:

  • component_names (Array)

    the component names as an array of symbols

Returns:

  • (Class)

    the created domain as a ruby Class



47
48
49
# File 'lib/domain/factory.rb', line 47

def scalar(*component_names)
  Class.new{ extend Scalar.new(*component_names) }
end

#union(*sub_domains) ⇒ Class

Factors a union domain

Parameters:

  • super_domain (Class)

    the super_domain of the factored domain

  • sub_domains (Array)

    an array of sub domains for the factored domain

Returns:

  • (Class)

    the created domain as a ruby Class



34
35
36
# File 'lib/domain/factory.rb', line 34

def union(*sub_domains)
  Class.new{ extend Union.new(*sub_domains) }
end