Class: Models::Item
- Inherits:
-
Object
- Object
- Models::Item
- Defined in:
- app/models/_item/container.rb,
app/models/_item/attachments.rb,
app/models/_item/slug.rb
Instance Attribute Summary collapse
-
#dependent ⇒ Object
Returns the value of attribute dependent.
- #slug ⇒ Object
Class Method Summary collapse
Instance Method Summary collapse
- #attachments ⇒ Object
- #attachments_as_images ⇒ Object
- #dependent! ⇒ Object
- #dependent? ⇒ Boolean
- #independent! ⇒ Object
- #independent? ⇒ Boolean
Instance Attribute Details
#dependent ⇒ Object
Returns the value of attribute dependent.
2 3 4 |
# File 'app/models/_item/container.rb', line 2 def dependent @dependent end |
#slug ⇒ Object
3 4 5 |
# File 'app/models/_item/slug.rb', line 3 def slug @slug ||= generate_slug end |
Class Method Details
.by_param(param) ⇒ Object
20 21 22 |
# File 'app/models/_item/slug.rb', line 20 def self.by_param param self.by_slug(param) || (BSON::ObjectId.legal?(param) && self.by_id(param)) end |
.by_param!(param) ⇒ Object
16 17 18 |
# File 'app/models/_item/slug.rb', line 16 def self.by_param! param by_param(param) || raise(Mongo::NotFound, "object with slug #{param} not found!") end |
Instance Method Details
#attachments ⇒ Object
2 3 4 |
# File 'app/models/_item/attachments.rb', line 2 def @attachments ||= [] end |
#attachments_as_images ⇒ Object
9 10 11 12 13 14 |
# File 'app/models/_item/attachments.rb', line 9 def # TODO3 remove sorting, use order defined in database _cache[:attachments_as_images] ||= . sort{|a, b| a.file.name <=> b.file.name}. collect{|o| {name: o.file.name, url: o.file.url, thumb_url: o.file.thumb.url, icon_url: o.file.icon.url}.to_openobject} end |
#dependent! ⇒ Object
6 |
# File 'app/models/_item/container.rb', line 6 def dependent!; self.dependent = true end |
#dependent? ⇒ Boolean
3 |
# File 'app/models/_item/container.rb', line 3 def dependent?; !!dependent end |
#independent! ⇒ Object
5 |
# File 'app/models/_item/container.rb', line 5 def independent!; remove_instance_variable :@dependent end |
#independent? ⇒ Boolean
4 |
# File 'app/models/_item/container.rb', line 4 def independent?; !dependent? end |