class Locomotive::Steam::ContentType
Public Class Methods
new(attributes = {})
click to toggle source
Calls superclass method
Locomotive::Steam::Models::Entity::new
# File lib/locomotive/steam/entities/content_type.rb, line 14 def initialize(attributes = {}) super({ order_by: '_position', order_direction: 'asc', recaptcha_required: false }.merge(attributes)) end
Public Instance Methods
field_label_of(name)
click to toggle source
# File lib/locomotive/steam/entities/content_type.rb, line 57 def field_label_of(name) fields_by_name[name].label.downcase end
fields()
click to toggle source
# File lib/locomotive/steam/entities/content_type.rb, line 22 def fields # Note: this returns an instance of the ContentTypeFieldRepository class self.entries_custom_fields end
fields_by_name()
click to toggle source
# File lib/locomotive/steam/entities/content_type.rb, line 27 def fields_by_name @fields_by_name ||= (fields.all.inject({}) do |memo, field| memo[field.name] = field memo end).with_indifferent_access end
label_field_name()
click to toggle source
# File lib/locomotive/steam/entities/content_type.rb, line 53 def label_field_name (self[:label_field_name] || fields.first.name).to_sym end
localized?()
click to toggle source
# File lib/locomotive/steam/entities/content_type.rb, line 40 def localized? !fields.localized_names.blank? end
localized_names()
click to toggle source
# File lib/locomotive/steam/entities/content_type.rb, line 34 def localized_names # FIXME: select type fields are a bit specific. The label of the options is localized # even if the select itself is not (see the _cast_select method in the content_entry entity class) fields.localized_names + select_fields.map(&:name) end
order_by()
click to toggle source
# File lib/locomotive/steam/entities/content_type.rb, line 61 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
persisted_field_names()
click to toggle source
# File lib/locomotive/steam/entities/content_type.rb, line 44 def persisted_field_names [].tap do |names| fields_by_name.each do |name, field| _name = field.persisted_name names << _name if _name end end end
recaptcha_required?()
click to toggle source
# File lib/locomotive/steam/entities/content_type.rb, line 72 def recaptcha_required? !!self.recaptcha_required end