Class: Pakyow::Reflection::Builders::Source Private
- Defined in:
- lib/pakyow/reflection/builders/source.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Instance Method Summary collapse
- #build(scope) ⇒ Object private
Methods inherited from Base
Constructor Details
This class inherits a constructor from Pakyow::Reflection::Builders::Base
Instance Method Details
#build(scope) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/pakyow/reflection/builders/source.rb', line 10 def build(scope) block = Proc.new do scope.attributes.each do |attribute| unless attributes.key?(attribute.name) attribute attribute.name, attribute.type end end scope.children.each do |child_scope| unless associations[:has_many].any? { |association| association.name == child_scope.plural_name } || associations[:has_one].any? { |association| association.name == child_scope.name } has_many child_scope.plural_name, dependent: :delete end end end (source_for_scope(scope) || define_source_for_scope(scope)).tap do |source| unless source.__source_location source.__source_location = block.source_location end source.class_eval(&block) end end |