Sha256: 00d87af7a89f550d9c4c733d9c8ff69b7c118582aa4bc20be4446e436c4ed3f5
Contents?: true
Size: 1 KB
Versions: 2
Compression:
Stored size: 1 KB
Contents
# frozen_string_literal: true module Consyncful ## # Provides common functionality of Mongoid models created from contentful # entries class Base include Mongoid::Document include Mongoid::Attributes::Dynamic cattr_accessor :model_map store_in collection: Consyncful.configuration.mongo_collection.to_s, client: Consyncful.configuration.mongo_client.to_s def self.contentful_model_name(name) self.model_map ||= {} self.model_map[name] = self end # rubocop:disable Lint/NestedMethodDefinition def self.references_many(name) has_and_belongs_to_many name.to_sym, class_name: 'Consyncful::Base', inverse_of: nil do def in_order _target.to_a.sort_by do |reference| _base[foreign_key].index(reference.id) end end end end # rubocop:enable Lint/NestedMethodDefinition def self.references_one(name) belongs_to name.to_sym, optional: true, class_name: 'Consyncful::Base' end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
consyncful-1.0.1 | lib/consyncful/base.rb |
consyncful-1.0.0 | lib/consyncful/base.rb |