Class: Sequel::Plugins::Paperclip::Interpolations
- Inherits:
-
Object
- Object
- Sequel::Plugins::Paperclip::Interpolations
- Defined in:
- lib/sequel_paperclip/interpolations.rb
Class Method Summary collapse
- .basename(attachment, model, style) ⇒ Object
- .extname(attachment, model, style) ⇒ Object
- .filename(attachment, model, style) ⇒ Object
- .filesize(attachment, model, style) ⇒ Object
- .format(attachment, model, style) ⇒ Object
- .host(attachment, model, style) ⇒ Object
- .id(attachment, model, style) ⇒ Object
- .interpolate(string, attachment, model, style) ⇒ Object
- .model(attachment, model, style) ⇒ Object
- .path(attachment, model, style) ⇒ Object
- .rails_env(attachment, model, style) ⇒ Object
- .rails_root(attachment, model, style) ⇒ Object
- .set(name, &block) ⇒ Object
- .style(attachment, model, style) ⇒ Object
Class Method Details
.basename(attachment, model, style) ⇒ Object
50 51 52 |
# File 'lib/sequel_paperclip/interpolations.rb', line 50 def self.basename(, model, style) model.send("#{.name}_basename") end |
.extname(attachment, model, style) ⇒ Object
54 55 56 |
# File 'lib/sequel_paperclip/interpolations.rb', line 54 def self.extname(, model, style) model.send("#{.name}_extname") end |
.filename(attachment, model, style) ⇒ Object
42 43 44 |
# File 'lib/sequel_paperclip/interpolations.rb', line 42 def self.filename(, model, style) model.send("#{.name}_filename") end |
.filesize(attachment, model, style) ⇒ Object
46 47 48 |
# File 'lib/sequel_paperclip/interpolations.rb', line 46 def self.filesize(, model, style) model.send("#{.name}_filesize") end |
.format(attachment, model, style) ⇒ Object
38 39 40 |
# File 'lib/sequel_paperclip/interpolations.rb', line 38 def self.format(, model, style) .[:styles][style][:format] end |
.host(attachment, model, style) ⇒ Object
26 27 28 |
# File 'lib/sequel_paperclip/interpolations.rb', line 26 def self.host(, model, style) "/system" end |
.id(attachment, model, style) ⇒ Object
17 18 19 20 |
# File 'lib/sequel_paperclip/interpolations.rb', line 17 def self.id(, model, style) raise ArgumentError, "record has no id" unless model.id model.id end |
.interpolate(string, attachment, model, style) ⇒ Object
11 12 13 14 15 |
# File 'lib/sequel_paperclip/interpolations.rb', line 11 def self.interpolate(string, , model, style) string.gsub(/:\w+:/i) do |tag| send(tag[1..-2], , model, style) end end |
.model(attachment, model, style) ⇒ Object
22 23 24 |
# File 'lib/sequel_paperclip/interpolations.rb', line 22 def self.model(, model, style) model.class.to_s.underscore.pluralize end |
.path(attachment, model, style) ⇒ Object
30 31 32 |
# File 'lib/sequel_paperclip/interpolations.rb', line 30 def self.path(, model, style) "#{Rails.root}/public/system" end |
.rails_env(attachment, model, style) ⇒ Object
62 63 64 |
# File 'lib/sequel_paperclip/interpolations.rb', line 62 def self.rails_env(, model, style) Rails.env end |
.rails_root(attachment, model, style) ⇒ Object
58 59 60 |
# File 'lib/sequel_paperclip/interpolations.rb', line 58 def self.rails_root(, model, style) Rails.root end |
.set(name, &block) ⇒ Object
5 6 7 8 9 |
# File 'lib/sequel_paperclip/interpolations.rb', line 5 def self.set(name, &block) (class << self; self; end).instance_eval do define_method(name, &block) end end |
.style(attachment, model, style) ⇒ Object
34 35 36 |
# File 'lib/sequel_paperclip/interpolations.rb', line 34 def self.style(, model, style) style end |