Class: PaperTrail::Human::Core::Presenter
- Inherits:
-
Object
- Object
- PaperTrail::Human::Core::Presenter
- Includes:
- AfterFormat
- Defined in:
- lib/paper_trail/human/core/presenter.rb
Instance Method Summary collapse
- #call(version, only: nil, except: nil) ⇒ Object
-
#initialize(configuration) ⇒ Presenter
constructor
A new instance of Presenter.
Constructor Details
#initialize(configuration) ⇒ Presenter
Returns a new instance of Presenter.
9 10 11 12 |
# File 'lib/paper_trail/human/core/presenter.rb', line 9 def initialize(configuration) @configuration = configuration @change_extractor = ChangeExtractor.new end |
Instance Method Details
#call(version, only: nil, except: nil) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/paper_trail/human/core/presenter.rb', line 14 def call(version, only: nil, except: nil) changes = @change_extractor.call(version) formatter = build_formatter(version) result = { user: @configuration.resolve_whodunnit(version.whodunnit), event: EventTranslator.call(version.event, translate: @configuration.translate_events), model: version.item_type, item_id: version.item_id, created_at: version.created_at, fields: build_fields(changes, formatter, version.event, only: only, except: except) } item_name = @configuration.resolve_item_name(version) result[:item_name] = item_name if item_name apply_after_format(result, version) end |