Sha256: 864166a65746745196700f558393609c0dc82418e022dde02b3f16de27147244

Contents?: true

Size: 1.31 KB

Versions: 2

Compression:

Stored size: 1.31 KB

Contents

require 'common_repository_model/collection'

class JournalVolume < CommonRepositoryModel::Collection
  def name_of_area_to_assign
    Journal::AREA_NAME.freeze
  end

  is_member_of :journals, class_name: "Journal", property: :is_volume_of
end

class Journal < CommonRepositoryModel::Collection
  AREA_NAME ='NDLIB-LAW'.freeze
  def name_of_area_to_assign
    AREA_NAME
  end

  has_members :volumes, class_name: "JournalVolume", property: :is_volume_of
end

class Clothing < CommonRepositoryModel::Data
end

class Job < CommonRepositoryModel::Collection
  has_and_belongs_to_many(
    :people,
    class_name: 'Person',
    property: :has_workers,
    inverse_of: :is_working_as
  )
end

class Family < CommonRepositoryModel::Collection
  has_members(
    :family_members,
    class_name: 'Person',
    property: :is_family_member_of
  )
end

class Person < CommonRepositoryModel::Collection

  is_member_of(
    :parents,
    class_name: 'Person',
    property: :is_child_of
  )

  has_members(
    :children,
    class_name: 'Person',
    property: :is_child_of
  )

  # People can be part of multiple families
  is_member_of(
    :families,
    class_name: 'Family',
    property: :is_family_member_of
  )

  has_and_belongs_to_many(
    :jobs,
    class_name: 'Job',
    property: :is_working_as,
    inverse_of: :has_workers
  )

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
common_repository_model-0.1.0 spec/support/spec_models.rb
common_repository_model-0.0.9 spec/support/spec_models.rb