Module: Shrine::Plugins::Model::AttachmentMethods

Defined in:
lib/shrine/plugins/model.rb

Instance Method Summary collapse

Instance Method Details

#included(klass) ⇒ Object

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.



29
30
31
32
# File 'lib/shrine/plugins/model.rb', line 29

def included(klass)
  super
  define_model_methods(@name) if model?
end

#initialize(name, model: true, **options) ⇒ Object

Allows disabling model behaviour:

Shrine::Attachment(:image)               # model (default)
Shrine::Attachment(:image, model: false) # entity


21
22
23
24
# File 'lib/shrine/plugins/model.rb', line 21

def initialize(name, model: true, **options)
  super(name, **options)
  @model = model
end