Module: Shrine::Attachment::ClassMethods

Included in:
Shrine::Attachment
Defined in:
lib/shrine/attachment.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#shrine_classObject

Returns the Shrine class that this attachment class is namespaced under.



13
14
15
# File 'lib/shrine/attachment.rb', line 13

def shrine_class
  @shrine_class
end

Instance Method Details

#[](*args, **options) ⇒ Object

Shorthand for ‘Attachment.new`.

Shrine::Attachment[:image]


25
26
27
# File 'lib/shrine/attachment.rb', line 25

def [](*args, **options)
  new(*args, **options)
end

#inspectObject

Since Attachment is anonymously subclassed when Shrine is subclassed, and then assigned to a constant of the Shrine subclass, make inspect reflect the likely name for the class.



18
19
20
# File 'lib/shrine/attachment.rb', line 18

def inspect
  "#{shrine_class.inspect}::Attachment"
end