Sha256: 9a128939a27fa314e9643f859e20d09ca952784a4b15aa83f18d466f05af3c2c
Contents?: true
Size: 1.28 KB
Versions: 8
Compression:
Stored size: 1.28 KB
Contents
module Locomotive module Steam class ContentTypeFieldRepository include Models::Repository attr_accessor :content_type # Entity mapping mapping :content_type_fields, entity: ContentTypeField do default_attribute :content_type, -> (repository) { repository.content_type } embedded_association :select_options, ContentTypeFieldSelectOptionRepository end def by_name(name) first { where(name: name) } end def selects query { where(type: :select) }.all end def associations query { where(k(:type, :in) => %i(belongs_to has_many many_to_many)) }.all end def no_associations query { where(k(:type, :nin) => %i(belongs_to has_many many_to_many)) }.all end def unique query { where(unique: true) }.all.inject({}) do |memo, field| memo[field.name] = field memo end end def required query { where(required: true) }.all end def localized_names query { where(localized: true) }.all.map(&:name) end def select_options(name) if field = first { where(name: name, type: :select) } field.select_options.all else nil end end end end end
Version data entries
8 entries across 8 versions & 1 rubygems