Class: AssetManager::Asset
Class Method Summary
collapse
Instance Method Summary
collapse
included
included, #translations_for_locales
Class Method Details
.accepted(file_type) ⇒ Object
65
66
67
68
69
70
71
72
|
# File 'app/models/asset_manager/asset.rb', line 65
def self.accepted(file_type)
if file_type
file_type = [file_type] unless file_type.kind_of?(Array)
where('file_type in (?)', file_type)
else
where('1=1')
end
end
|
.find_ordered(ids) ⇒ Object
74
75
76
77
|
# File 'app/models/asset_manager/asset.rb', line 74
def self.find_ordered(ids)
collection = Asset.find(ids)
ids.map { |id| collection.find { |resource| resource.id == id.to_i } }
end
|
.public(public) ⇒ Object
54
55
56
57
58
59
60
61
62
63
|
# File 'app/models/asset_manager/asset.rb', line 54
def self.public(public)
case public
when :public
where(public: true)
when :private
where(public: false)
else
where('1=1')
end
end
|
Instance Method Details
#alt ⇒ Object
79
80
81
|
# File 'app/models/asset_manager/asset.rb', line 79
def alt
description
end
|
#asset_instances ⇒ Object
95
96
97
|
# File 'app/models/asset_manager/asset.rb', line 95
def asset_instances
public ? asset_public_instances : asset_private_instances
end
|
#has_this_instance_context?(ic) ⇒ Boolean
91
92
93
|
# File 'app/models/asset_manager/asset.rb', line 91
def has_this_instance_context?(ic)
asset_instances.any? { |ai| ai.instance_context.to_sym == ic }
end
|
#is_image? ⇒ Boolean
83
84
85
|
# File 'app/models/asset_manager/asset.rb', line 83
def is_image?
%w(jpg png jpeg gif).include?(file_type)
end
|
#is_pdf? ⇒ Boolean
87
88
89
|
# File 'app/models/asset_manager/asset.rb', line 87
def is_pdf?
file_type == 'pdf'
end
|