Module: Fried::Schema::Struct::ClassMethods
- Defined in:
- lib/fried/schema/struct.rb
Constant Summary collapse
- Noop =
-> { nil }
Instance Method Summary collapse
-
#attribute(name, type, default: Noop) ⇒ Symbol
Defines an attr_accessor with given name, type checking and optional default value.
Instance Method Details
#attribute(name, type, default: Noop) ⇒ Symbol
Defines an attr_accessor with given name, type checking and optional default value
35 36 37 38 39 40 41 |
# File 'lib/fried/schema/struct.rb', line 35 def attribute(name, type, default: Noop) schema = CreateDefinitionIfMissing.(self) definer = Attribute::Definition attribute_definition = definer.new(name, type, default) schema.add_attribute(attribute_definition) Attribute::DefineMethods.(attribute_definition, self) end |