Class: Symphonia::EntityDecorator
- Defined in:
- lib/symphonia/entity_decorator.rb
Overview
This class decorate general entity
Instance Method Summary collapse
- #attributes(&block) ⇒ Object
-
#initialize(entity, view_context) ⇒ EntityDecorator
constructor
A new instance of EntityDecorator.
- #label(name, **options) ⇒ Object
- #registered_attributes ⇒ Object
Constructor Details
#initialize(entity, view_context) ⇒ EntityDecorator
Returns a new instance of EntityDecorator.
5 6 7 8 |
# File 'lib/symphonia/entity_decorator.rb', line 5 def initialize(entity, view_context) @view_context = view_context super(entity) end |
Instance Method Details
#attributes(&block) ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/symphonia/entity_decorator.rb', line 18 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 |
#label(name, **options) ⇒ Object
14 15 16 |
# File 'lib/symphonia/entity_decorator.rb', line 14 def label(name, **) __getobj__.class.human_attribute_name name, end |
#registered_attributes ⇒ Object
10 11 12 |
# File 'lib/symphonia/entity_decorator.rb', line 10 def registered_attributes __getobj__.class.registered_attributes end |