Sha256: 86e737027f89b3330527f0de367dfd2ca324f8446978587d424ffe953fc61ade
Contents?: true
Size: 938 Bytes
Versions: 35
Compression:
Stored size: 938 Bytes
Contents
# frozen_string_literal: true module Tramway::Core::Attributes::ViewHelper def build_viewable_value(object, attribute) value = try(attribute[0]) ? send(attribute[0]) : object.send(attribute[0]) return state_machine_view(object, attribute[0]) if state_machine? object, attribute[0] view_by_value object, value, attribute end def state_machine?(object, attribute_name) attribute_name.to_s.in? object.class.state_machines_names.map(&:to_s) end def view_by_value(object, value, attribute) if value.class.in? [ActiveSupport::TimeWithZone, DateTime, Time] datetime_view(attribute[1]) elsif value.class == PhotoUploader image_view(object.send(attribute[0])) elsif value.class == FileUploader file_view(object.send(attribute[0])) elsif value.is_a? Enumerize::Value enumerize_view(value) elsif value.is_a? Hash yaml_view(value) else value end end end
Version data entries
35 entries across 35 versions & 1 rubygems