Sha256: c47d38951e81961d6b9835a8b099d6ebfce93e77f0aaede4aae2d9c3ad5875e8
Contents?: true
Size: 1.55 KB
Versions: 2
Compression:
Stored size: 1.55 KB
Contents
module Locomotive module Wagon class ContentTypeFieldDecorator < SimpleDelegator include ToHashConcern def initialize(entity, persisted = false) @persisted = persisted super(entity) end def __attributes__ %i(name type label hint required localized unique position text_formatting select_options target inverse_of order_by ui_enabled) end def type self[:type] end def hint self[:hint] end def position self[:position] end def text_formatting return nil unless type == :text self[:text_formatting] end def target return nil unless is_relationship? self.target_id end def inverse_of return nil unless is_relationship? self[:inverse_of] end def order_by return nil unless is_relationship? self[:order_by] end def ui_enabled return nil unless is_relationship? self[:order_by] end def select_options return nil if type.to_sym != :select || @persisted @_select_options ||= __getobj__.select_options.all.map { |o| SelectOptionDecorator.new(o) } end class SelectOptionDecorator < SimpleDelegator include ToHashConcern def __attributes__ %i(name) end def name translations = __getobj__.name.translations translations.empty? ? translations[:any] : translations end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems