module Shrine::Attachment::InstanceMethods

  1. lib/shrine/attachment.rb

Methods

Public Class

  1. new

Public Instance

  1. attachment_name
  2. inspect
  3. options
  4. shrine_class

Public Instance Aliases

to_s -> inspect

Public Class methods

new(name, **options)

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.

[show source]
   # File lib/shrine/attachment.rb
34 def initialize(name, **options)
35   @name    = name.to_sym
36   @options = options
37 end

Public Instance methods

attachment_name()

Returns name of the attachment this module provides.

[show source]
   # File lib/shrine/attachment.rb
40 def attachment_name
41   @name
42 end
inspect()

Returns class name with attachment name included.

Shrine::Attachment.new(:image).to_s #=> "#<Shrine::Attachment(image)>"
[show source]
   # File lib/shrine/attachment.rb
52 def inspect
53   "#<#{self.class.inspect}(#{@name})>"
54 end
options()

Returns options that are to be passed to the Attacher.

[show source]
   # File lib/shrine/attachment.rb
45 def options
46   @options
47 end
shrine_class()

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

[show source]
   # File lib/shrine/attachment.rb
59 def shrine_class
60   self.class.shrine_class
61 end