Sha256: fc192973f9e88686245aaa20afe7abe30c4a8838acd28d1b2ce126ed8bcb4369

Contents?: true

Size: 1.25 KB

Versions: 1

Compression:

Stored size: 1.25 KB

Contents

require "terrestrial"
require "terrestrial/relational_store"
require "terrestrial/relation_mapping"
require "terrestrial/lazy_collection"
require "terrestrial/collection_mutability_proxy"
require "terrestrial/lazy_object_proxy"
require "terrestrial/dataset"
require "terrestrial/query_order"
require "terrestrial/one_to_many_association"
require "terrestrial/many_to_one_association"
require "terrestrial/many_to_many_association"
require "terrestrial/subset_queries_proxy"
require "support/object_graph_setup"

RSpec.shared_context "object store setup" do
  include_context "object graph setup"

  let(:user_store) { object_store[:users] }

  let(:object_store) {
    Terrestrial.object_store(config: mappings)
  }

  let(:mappings) {
    Terrestrial.config(datastore)
      .setup_mapping(:users) { |users|
        users.has_many(:posts, foreign_key: :author_id)
      }
      .setup_mapping(:posts) { |posts|
        posts.belongs_to(:author, mapping_name: :users)
        posts.has_many(:comments)
        posts.has_many_through(:categories)
      }
      .setup_mapping(:comments) { |comments|
        comments.belongs_to(:commenter, mapping_name: :users)
      }
      .setup_mapping(:categories) { |categories|
        categories.has_many_through(:posts)
      }
  }
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
terrestrial-0.5.0 spec/support/object_store_setup.rb