Module: Dis::Model::ClassMethods
- Defined in:
- lib/dis/model/class_methods.rb
Instance Method Summary collapse
-
#default_dis_attributes ⇒ Object
Returns the default attribute names.
-
#dis_attributes ⇒ Object
Returns the mapping of attribute names.
-
#dis_attributes=(new_attributes) ⇒ Object
Sets the current mapping of attribute names.
-
#dis_type ⇒ Object
Returns the storage type name, which Dis will use for directory scoping.
-
#dis_type=(new_type) ⇒ Object
Sets the storage type name.
-
#validates_data_presence ⇒ Object
Adds a presence validation on the
data
attribute.
Instance Method Details
#default_dis_attributes ⇒ Object
Returns the default attribute names.
53 54 55 56 57 58 59 60 |
# File 'lib/dis/model/class_methods.rb', line 53 def default_dis_attributes { content_hash: :content_hash, content_length: :content_length, content_type: :content_type, filename: :filename } end |
#dis_attributes ⇒ Object
Returns the mapping of attribute names.
7 8 9 |
# File 'lib/dis/model/class_methods.rb', line 7 def dis_attributes default_dis_attributes.merge(@dis_attributes ||= {}) end |
#dis_attributes=(new_attributes) ⇒ Object
18 19 20 |
# File 'lib/dis/model/class_methods.rb', line 18 def dis_attributes=(new_attributes) @dis_attributes = new_attributes end |
#dis_type ⇒ Object
Returns the storage type name, which Dis will use for directory scoping. Defaults to the name of the database table.
class Document < ActiveRecord::Base; end
Document.dis_type # => "documents"
27 28 29 |
# File 'lib/dis/model/class_methods.rb', line 27 def dis_type @dis_type ||= table_name end |
#dis_type=(new_type) ⇒ Object
Sets the storage type name.
Take care not to set the same name for multiple models, this will cause data loss when a record is destroyed.
35 36 37 |
# File 'lib/dis/model/class_methods.rb', line 35 def dis_type=(new_type) @dis_type = new_type end |
#validates_data_presence ⇒ Object
48 49 50 |
# File 'lib/dis/model/class_methods.rb', line 48 def validates_data_presence validates_with Dis::Validations::DataPresence end |