Public Class methods
new(name, model: true, **options)
Allows disabling model behaviour:
Shrine::Attachment(:image) # model (default) Shrine::Attachment(:image, model: false) # entity
# File lib/shrine/plugins/model.rb 21 def initialize(name, model: true, **options) 22 super(name, **options) 23 @model = model 24 end
Public Instance methods
We define model methods only on inclusion. This gives other plugins the ability to disable model behaviour for entity classes. In this case we want to skip defining model methods as well.
# File lib/shrine/plugins/model.rb 29 def included(klass) 30 super 31 define_model_methods(@name) if model? 32 end