module Shrine::Plugins::Model::AttachmentMethods

  1. lib/shrine/plugins/model.rb


Public Class

  1. new

Public Instance

  1. included

Public Class methods

new(name, model: true, **options)

Allows disabling model behaviour:

Shrine::Attachment(:image)               # model (default)
Shrine::Attachment(:image, model: false) # entity
[show source]
   # 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.

[show source]
   # File lib/shrine/plugins/model.rb
29 def included(klass)
30   super
31   define_model_methods(@name) if model?
32 end