Module: ErpTechSvcs::Extensions::ActiveRecord::HasFileAssets::InstanceMethods
- Defined in:
- lib/erp_tech_svcs/extensions/active_record/has_file_assets.rb
Instance Method Summary collapse
-
#add_file(data, path = nil, capabilities = nil) ⇒ Object
Capabilites can be passed via a hash { :download => [‘admin’, ‘employee’], :edit => [‘admin’] }.
- #images ⇒ Object
- #templates ⇒ Object
Instance Method Details
#add_file(data, path = nil, capabilities = nil) ⇒ Object
Capabilites can be passed via a hash
:download => ['admin', 'employee'],
:edit => ['admin']
30 31 32 33 34 35 36 37 38 39 |
# File 'lib/erp_tech_svcs/extensions/active_record/has_file_assets.rb', line 30 def add_file(data, path=nil, capabilities=nil) file_asset = FileAsset.create!(:file_asset_holder => self, :base_path => path, :data => data) #set capabilites if they are passed capabilities.each do |capability_type, roles| file_asset.add_capability(capability_type, nil, roles) end if capabilities file_asset end |
#images ⇒ Object
41 42 43 |
# File 'lib/erp_tech_svcs/extensions/active_record/has_file_assets.rb', line 41 def images self.files.where('type = ?', 'Image') end |
#templates ⇒ Object
45 46 47 |
# File 'lib/erp_tech_svcs/extensions/active_record/has_file_assets.rb', line 45 def templates self.files.where('type = ?', 'Template') end |