Sha256: 8e6f89590b0a445ceb076d183aee83215393e7c83a85c00a98eae3fac99f9274
Contents?: true
Size: 1.07 KB
Versions: 4
Compression:
Stored size: 1.07 KB
Contents
module Locomotive::Steam class ContentType include Locomotive::Steam::Models::Entity extend Forwardable def_delegators :fields, :associations, :selects def initialize(attributes = {}) super({ order_by: '_position', order_direction: 'asc' }.merge(attributes)) end def fields # Note: this returns an instance of the ContentTypeFieldRepository class self.entries_custom_fields end def fields_by_name @fields_by_name ||= (fields.all.inject({}) do |memo, field| memo[field.name] = field memo end).with_indifferent_access end def localized_names fields.localized_names + selects.map(&:name) end def label_field_name (self[:label_field_name] || fields.first.name).to_sym end def order_by name = self[:order_by] == 'manually' ? '_position' : self[:order_by] # check if name is an id of field if field = fields.find(name) name = field.name end { name.to_sym => self.order_direction.to_s } end end end
Version data entries
4 entries across 4 versions & 1 rubygems