Module: Shrine::Attachment::InstanceMethods
- Included in:
- Shrine::Attachment
- Defined in:
- lib/shrine/attachment.rb
Instance Method Summary collapse
-
#attachment_name ⇒ Object
Returns name of the attachment this module provides.
-
#initialize(name, **options) ⇒ Object
Instantiates an attachment module for a given attribute name, which can then be included to a model class.
-
#inspect ⇒ Object
(also: #to_s)
Returns class name with attachment name included.
-
#options ⇒ Object
Returns options that are to be passed to the Attacher.
-
#shrine_class ⇒ Object
Returns the Shrine class that this attachment’s class is namespaced under.
Instance Method Details
#attachment_name ⇒ Object
Returns name of the attachment this module provides.
40 41 42 |
# File 'lib/shrine/attachment.rb', line 40 def @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, **) @name = name.to_sym @options = end |
#inspect ⇒ Object 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 |
#options ⇒ Object
Returns options that are to be passed to the Attacher.
45 46 47 |
# File 'lib/shrine/attachment.rb', line 45 def @options end |
#shrine_class ⇒ Object
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 |