Sha256: a5abc55836b39115caa233ea96035cb6002d19233d05f031b3d3952bd221e976
Contents?: true
Size: 804 Bytes
Versions: 32
Compression:
Stored size: 804 Bytes
Contents
module Symphonia # This class decorate general entity class EntityDecorator < SimpleDelegator def initialize(entity, view_context) @view_context = view_context super(entity) end def registered_attributes __getobj__.class.registered_attributes end def label(name, **options) __getobj__.class.human_attribute_name name, options end def attributes(&block) registered_attributes.collect do |name, attr| value = __getobj__.format_value(name, @view_context) yield name, value, attr if block_given? [name, value] end.to_h end # def name # @name ||= super || registered_attributes.find { |name, a| name == :name }.last # end # # def title # super || name || to_s # end end end
Version data entries
32 entries across 32 versions & 1 rubygems