Module: Shrine::Attacher::ClassMethods
- Included in:
- Shrine::Attacher
- Defined in:
- lib/shrine/attacher.rb
Instance Attribute Summary collapse
-
#shrine_class ⇒ Object
Returns the Shrine class that this attacher class is namespaced under.
Instance Method Summary collapse
-
#from_data(data, **options) ⇒ Object
Initializes the attacher from a data hash generated from ‘Attacher#data`.
-
#inspect ⇒ Object
Since Attacher 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.
Instance Attribute Details
#shrine_class ⇒ Object
Returns the Shrine class that this attacher class is namespaced under.
12 13 14 |
# File 'lib/shrine/attacher.rb', line 12 def shrine_class @shrine_class end |
Instance Method Details
#from_data(data, **options) ⇒ Object
Initializes the attacher from a data hash generated from ‘Attacher#data`.
attacher = Attacher.from_data({ "id" => "...", "storage" => "...", "metadata" => { ... } })
attacher.file #=> #<Shrine::UploadedFile>
25 26 27 28 29 |
# File 'lib/shrine/attacher.rb', line 25 def from_data(data, **) attacher = new(**) attacher.load_data(data) attacher end |
#inspect ⇒ Object
Since Attacher 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.
17 18 19 |
# File 'lib/shrine/attacher.rb', line 17 def inspect "#{shrine_class.inspect}::Attacher" end |