Class: DeadSimpleCMS::FileUploader::Base
- Inherits:
-
Object
- Object
- DeadSimpleCMS::FileUploader::Base
- Defined in:
- lib/dead_simple_cms/file_uploader/base.rb
Overview
Base file uploader class. Inherit from this to build your own uploaders for files.
Instance Attribute Summary collapse
-
#file_attribute ⇒ Object
readonly
Returns the value of attribute file_attribute.
Instance Method Summary collapse
-
#initialize(file_attribute) ⇒ Base
constructor
A new instance of Base.
-
#path(namespace = "dead_simple_cms") ⇒ Object
Public: We need to have all these nesting to protect against corner-case collisons.
- #upload! ⇒ Object
- #url ⇒ Object
Constructor Details
#initialize(file_attribute) ⇒ Base
Returns a new instance of Base.
9 10 11 |
# File 'lib/dead_simple_cms/file_uploader/base.rb', line 9 def initialize(file_attribute) @file_attribute = file_attribute end |
Instance Attribute Details
#file_attribute ⇒ Object (readonly)
Returns the value of attribute file_attribute.
6 7 8 |
# File 'lib/dead_simple_cms/file_uploader/base.rb', line 6 def file_attribute @file_attribute end |
Instance Method Details
#path(namespace = "dead_simple_cms") ⇒ Object
Public: We need to have all these nesting to protect against corner-case collisons.
22 23 24 25 |
# File 'lib/dead_simple_cms/file_uploader/base.rb', line 22 def path(namespace="dead_simple_cms") # dead_simple_cms/<section>/<group>/attribute.jpg @path ||= [namespace, *[file_attribute.section, *file_attribute.group_hierarchy, file_attribute].map(&:identifier)].compact * "/" + "." + file_ext end |
#upload! ⇒ Object
13 14 15 |
# File 'lib/dead_simple_cms/file_uploader/base.rb', line 13 def upload! raise NotImplementedError, "Please overwrite this with your own upload functionality." end |
#url ⇒ Object
17 18 19 |
# File 'lib/dead_simple_cms/file_uploader/base.rb', line 17 def url raise NotImplementedError, "Please overwrite this with your own url constructor." end |