Class: Dao::Upload::Placeholder
- Inherits:
-
String
- Object
- String
- Dao::Upload::Placeholder
- Defined in:
- lib/dao/upload.rb
Instance Attribute Summary collapse
-
#path ⇒ Object
Returns the value of attribute path.
-
#url ⇒ Object
Returns the value of attribute url.
Class Method Summary collapse
Instance Method Summary collapse
- #absolute? ⇒ Boolean
- #basename ⇒ Object
- #default_path ⇒ Object
- #default_url ⇒ Object
-
#initialize(placeholder = '', options = {}) ⇒ Placeholder
constructor
A new instance of Placeholder.
Constructor Details
#initialize(placeholder = '', options = {}) ⇒ Placeholder
Returns a new instance of Placeholder.
383 384 385 386 387 388 |
# File 'lib/dao/upload.rb', line 383 def initialize(placeholder = '', = {}) replace(placeholder.to_s) . @url = [:url] || default_url @path = [:path] || default_path end |
Instance Attribute Details
#path ⇒ Object
Returns the value of attribute path.
381 382 383 |
# File 'lib/dao/upload.rb', line 381 def path @path end |
#url ⇒ Object
Returns the value of attribute url.
380 381 382 |
# File 'lib/dao/upload.rb', line 380 def url @url end |
Class Method Details
.root ⇒ Object
376 377 378 |
# File 'lib/dao/upload.rb', line 376 def Placeholder.root File.join(Rails.root, "app", "assets", "placeholders") end |
.route ⇒ Object
372 373 374 |
# File 'lib/dao/upload.rb', line 372 def Placeholder.route "/assets" end |
Instance Method Details
#absolute? ⇒ Boolean
404 405 406 |
# File 'lib/dao/upload.rb', line 404 def absolute? self =~ %r|\A([^:/]++:/)?/| end |
#basename ⇒ Object
400 401 402 |
# File 'lib/dao/upload.rb', line 400 def basename File.basename(self) end |
#default_path ⇒ Object
395 396 397 398 |
# File 'lib/dao/upload.rb', line 395 def default_path return nil if blank? absolute? ? nil : File.join(Placeholder.root, self) end |
#default_url ⇒ Object
390 391 392 393 |
# File 'lib/dao/upload.rb', line 390 def default_url return nil if blank? absolute? ? self : File.join(Placeholder.route, self) end |