Class: DeadSimpleCMS::Attribute::Type::File
- Defined in:
- lib/dead_simple_cms/attribute/type/all.rb
Overview
Public: File attributes are stored at some publicly accessible url.
Direct Known Subclasses
Constant Summary
Constants inherited from Base
Instance Attribute Summary collapse
-
#data ⇒ Object
Returns the value of attribute data.
-
#file_ext ⇒ Object
Returns the value of attribute file_ext.
Attributes inherited from Base
#group_hierarchy, #input_type, #required, #section
Instance Method Summary collapse
-
#initialize(identifier, options = {}) ⇒ File
constructor
A new instance of File.
-
#upload! ⇒ Object
Public: Takes the current #value, detects if its an object to upload and replaces the #value with the url to be stored in the CMS.
Methods inherited from Base
#default, #hint, #inspect, #length, #root_group?, #section_identifier, #value, #value=
Constructor Details
#initialize(identifier, options = {}) ⇒ File
Returns a new instance of File.
85 86 87 88 89 |
# File 'lib/dead_simple_cms/attribute/type/all.rb', line 85 def initialize(identifier, ={}) @data = [:data] @file_ext = [:file_ext] || "dat" super end |
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data.
79 80 81 |
# File 'lib/dead_simple_cms/attribute/type/all.rb', line 79 def data @data end |
#file_ext ⇒ Object
Returns the value of attribute file_ext.
79 80 81 |
# File 'lib/dead_simple_cms/attribute/type/all.rb', line 79 def file_ext @file_ext end |
Instance Method Details
#upload! ⇒ Object
Public: Takes the current #value, detects if its an object to upload and replaces the #value with the url to be stored in the CMS.
93 94 95 96 97 98 99 100 |
# File 'lib/dead_simple_cms/attribute/type/all.rb', line 93 def upload! raise NotImplementedError, "Please define an uploader class (see DeadSimpleCMS::FileUploader::Base)" unless uploader_class return unless data s3_uploader = uploader_class.new(self) s3_uploader.upload! self.value = s3_uploader.url end |