Module: Shrine::Attachment::InstanceMethods

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

Instance Method Summary collapse

Instance Method Details

#attachment_nameObject

Returns name of the attachment this module provides.



40
41
42
# File 'lib/shrine/attachment.rb', line 40

def attachment_name
  @name
end

#initialize(name, **options) ⇒ Object

Instantiates an attachment module for a given attribute name, which can then be included to a model class. Second argument will be passed to an attacher module.



34
35
36
37
# File 'lib/shrine/attachment.rb', line 34

def initialize(name, **options)
  @name    = name.to_sym
  @options = options
end

#inspectObject Also known as: to_s

Returns class name with attachment name included.

Shrine::Attachment.new(:image).to_s #=> "#<Shrine::Attachment(image)>"


52
53
54
# File 'lib/shrine/attachment.rb', line 52

def inspect
  "#<#{self.class.inspect}(#{@name})>"
end

#optionsObject

Returns options that are to be passed to the Attacher.



45
46
47
# File 'lib/shrine/attachment.rb', line 45

def options
  @options
end

#shrine_classObject

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



59
60
61
# File 'lib/shrine/attachment.rb', line 59

def shrine_class
  self.class.shrine_class
end