Class: Pakyow::Data::Container Private
- Inherits:
-
Object
- Object
- Pakyow::Data::Container
- Defined in:
- lib/pakyow/data/container.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 Attribute Summary collapse
- #connection ⇒ Object readonly private
- #sources ⇒ Object readonly private
Instance Method Summary collapse
- #finalize_associations!(other_containers) ⇒ Object private
- #finalize_sources!(other_containers) ⇒ Object private
-
#initialize(connection:, sources:, objects:) ⇒ Container
constructor
private
A new instance of Container.
- #object(object_name) ⇒ Object private
- #source(source_name) ⇒ Object private
Constructor Details
#initialize(connection:, sources:, objects:) ⇒ Container
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.
Returns a new instance of Container.
13 14 15 16 17 18 19 |
# File 'lib/pakyow/data/container.rb', line 13 def initialize(connection:, sources:, objects:) @connection, @sources = connection, sources @object_map = objects.each_with_object({}) { |object, map| map[object.__object_name.name] = object } end |
Instance Attribute Details
#connection ⇒ Object (readonly)
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.
11 12 13 |
# File 'lib/pakyow/data/container.rb', line 11 def connection @connection end |
#sources ⇒ Object (readonly)
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.
11 12 13 |
# File 'lib/pakyow/data/container.rb', line 11 def sources @sources end |
Instance Method Details
#finalize_associations!(other_containers) ⇒ 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.
38 39 40 41 42 43 44 45 46 47 |
# File 'lib/pakyow/data/container.rb', line 38 def finalize_associations!(other_containers) @sources.each do |source| discover_has_and_belongs_to!(source, other_containers) end @sources.each do |source| set_container_for_source!(source) define_reciprocal_associations!(source, other_containers) end end |
#finalize_sources!(other_containers) ⇒ 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.
49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/pakyow/data/container.rb', line 49 def finalize_sources!(other_containers) @sources.each do |source| mixin_commands!(source) mixin_dataset_methods!(source) define_attributes_for_associations!(source, other_containers) define_queries_for_attributes!(source) wrap_defined_queries!(source) define_methods_for_associations!(source) define_methods_for_objects!(source) finalize_source_types!(source) end end |
#object(object_name) ⇒ 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.
34 35 36 |
# File 'lib/pakyow/data/container.rb', line 34 def object(object_name) @object_map.fetch(object_name, Object) end |
#source(source_name) ⇒ 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.
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/pakyow/data/container.rb', line 21 def source(source_name) plural_source_name = Support.inflector.pluralize(source_name).to_sym if found_source = sources.find { |source| source.plural_name == plural_source_name } found_source.new( @connection.dataset_for_source(found_source) ) end end |