module Declarative::Schema::DSL
Constants
- NestedBuilder
Public Instance Methods
defaults(options={}, &block)
click to toggle source
# File lib/declarative/schema.rb, line 28 def defaults(options={}, &block) heritage.record(:defaults, options, &block) # Always convert arrays to Variables::Append instructions. options = options.merge( Defaults.wrap_arrays(options) ) block = wrap_arrays_from_block(block) if block_given? _defaults.merge!(options, &block) end
definition_class()
click to toggle source
# File lib/declarative/schema.rb, line 42 def definition_class # TODO: test me. Definitions::Definition end
definitions()
click to toggle source
# File lib/declarative/schema.rb, line 38 def definitions @definitions ||= Definitions.new(definition_class) end
property(name, options={}, &block)
click to toggle source
# File lib/declarative/schema.rb, line 22 def property(name, options={}, &block) heritage.record(:property, name, options, &block) build_definition(name, options, &block) end
Private Instance Methods
_defaults()
click to toggle source
# File lib/declarative/schema.rb, line 59 def _defaults @defaults ||= Declarative::Defaults.new end
build_definition(name, options={}, &block)
click to toggle source
# File lib/declarative/schema.rb, line 47 def build_definition(name, options={}, &block) default_options = { _base: default_nested_class, _defaults: _defaults } default_options[:_nested_builder] = nested_builder if block # options = options.merge( Defaults.wrap_arrays(options) ) definitions.add(name, default_options.merge(options), &block) end
nested_builder()
click to toggle source
# File lib/declarative/schema.rb, line 63 def nested_builder NestedBuilder # default implementation. end
wrap_arrays_from_block(block)
click to toggle source
When called, executes `block` and wraps all array values in Variables::Append. This is the default behavior in older versions and allows to provide arrays for default values that will be prepended.
# File lib/declarative/schema.rb, line 77 def wrap_arrays_from_block(block) ->(*args) { options = block.(*args) options.merge( Defaults.wrap_arrays( options ) ) } end