module Shrine::Plugins::Hanami::AttachmentMethods
Public Class Methods
new(name, **options)
click to toggle source
Calls superclass method
# File lib/shrine/plugins/hanami.rb, line 9 def initialize(name, **options) super module_eval <<-RUBY, __FILE__, __LINE__ + 1 module EntitySupport attr_reader :attributes def initialize(attributes) attachment = attributes[:#{name}] @_#{name} = attachment self.#{name}_attacher super(attributes) end def #{name}_data=(data) @#{name}_data = data end def #{name}_data super || @#{name}_data end def #{name} @_#{name} || super end def attributes @_#{name} ? super.merge(#{name}: @_#{name}) : super end end prepend EntitySupport RUBY end