Class: Algebrick::DSL::TypeDefinitionScope
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods included from TypeCheck
#Child!, #Child?, #Match!, #Match?, #Type!, #Type?
Methods included from Shortcuts
#atom, #type
Constructor Details
Returns a new instance of TypeDefinitionScope.
33
34
35
36
37
|
# File 'lib/algebrick/dsl.rb', line 33
def initialize(new_type, &block)
@new_type = Type! new_type, ProductVariant, ParametrizedType
instance_exec @new_type, &block
@new_type.kind if @new_type.is_a? ProductVariant
end
|
Instance Attribute Details
Returns the value of attribute new_type.
31
32
33
|
# File 'lib/algebrick/dsl.rb', line 31
def new_type
@new_type
end
|
Instance Method Details
#all_field_readers ⇒ Object
Also known as:
all_readers
66
67
68
69
|
# File 'lib/algebrick/dsl.rb', line 66
def all_field_readers
@new_type.add_all_field_method_readers
self
end
|
#field_readers(*names) ⇒ Object
Also known as:
readers
59
60
61
62
|
# File 'lib/algebrick/dsl.rb', line 59
def field_readers(*names)
@new_type.add_field_method_readers *names
self
end
|
#fields(*fields) ⇒ Object
39
40
41
42
|
# File 'lib/algebrick/dsl.rb', line 39
def fields(*fields)
@new_type.set_fields fields.first.is_a?(Hash) ? fields.first : fields
self
end
|
#fields!(*fields) ⇒ Object
44
45
46
47
|
# File 'lib/algebrick/dsl.rb', line 44
def fields!(*fields)
fields(*fields)
all_readers
end
|
49
50
51
52
|
# File 'lib/algebrick/dsl.rb', line 49
def final!
@new_type.final!
self
end
|
#variants(*variants) ⇒ Object
54
55
56
57
|
# File 'lib/algebrick/dsl.rb', line 54
def variants(*variants)
@new_type.set_variants *variants
self
end
|