class Locomotive::Steam::ContentTypeField
Attributes
content_type[RW]
Public Class Methods
new(attributes = {})
click to toggle source
Calls superclass method
Locomotive::Steam::Models::Entity::new
# File lib/locomotive/steam/entities/content_type_field.rb, line 9 def initialize(attributes = {}) super({ type: :string, localized: false, required: false, unique: false, default: nil }.merge(attributes)) end
Public Instance Methods
association_options()
click to toggle source
# File lib/locomotive/steam/entities/content_type_field.rb, line 52 def association_options { target_id: target_id, inverse_of: self[:inverse_of], order_by: order_by } end
class_name()
click to toggle source
# File lib/locomotive/steam/entities/content_type_field.rb, line 23 def class_name self[:class_name] || self[:target] end
Also aliased as: target
is_relationship?()
click to toggle source
# File lib/locomotive/steam/entities/content_type_field.rb, line 60 def is_relationship? %i(belongs_to has_many many_to_many).include?(self.type) end
localized?()
click to toggle source
# File lib/locomotive/steam/entities/content_type_field.rb, line 50 def localized?; self[:localized]; end
order_by()
click to toggle source
# File lib/locomotive/steam/entities/content_type_field.rb, line 27 def order_by if (order_by = self[:order_by]).present? # from Filesystem -> string, from MongoDB -> array (string transformed by Engine) name, direction = order_by.respond_to?(:each) ? order_by : order_by.split { name.to_sym => direction || 'asc' } else type == :has_many ? { :"position_in_#{self[:inverse_of]}" => 'asc' } : nil end end
persisted_name()
click to toggle source
# File lib/locomotive/steam/entities/content_type_field.rb, line 64 def persisted_name case type when :belongs_to, :select then "#{name}_id" when :many_to_many then "#{name.singularize}_ids" when :has_many then nil when :password then nil else name end end
required?()
click to toggle source
# File lib/locomotive/steam/entities/content_type_field.rb, line 49 def required?; self[:required]; end
target_id()
click to toggle source
# File lib/locomotive/steam/entities/content_type_field.rb, line 39 def target_id return @target_id if @target_id @target_id = if self.target =~ Locomotive::Steam::CONTENT_ENTRY_ENGINE_CLASS_NAME $1 else self.target end end
type()
click to toggle source
# File lib/locomotive/steam/entities/content_type_field.rb, line 19 def type self[:type].try(:to_sym) end