Class: Caboose::MediaCategory

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/caboose/media_category.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.top_file_category(site_id) ⇒ Object



14
15
16
# File 'app/models/caboose/media_category.rb', line 14

def self.top_file_category(site_id)
  return self.where("parent_id is null and site_id = ? and name = ?", site_id, 'Files').first
end

.top_image_category(site_id) ⇒ Object



10
11
12
# File 'app/models/caboose/media_category.rb', line 10

def self.top_image_category(site_id)
  return self.where("parent_id is null and site_id = ? and name = ?", site_id, 'Images').first
end

Instance Method Details

#api_hashObject



18
19
20
21
22
23
24
25
26
27
28
# File 'app/models/caboose/media_category.rb', line 18

def api_hash
  {
    :id => self.id,
    :parent_id => self.parent_id,
    :site_id => self.site_id,      
    :name => self.name,
    :children => self.children.collect { |child| child.api_hash },
    :images => self.media_images.collect { |img| img.api_hash },
    :files => self.media_files.collect { |file| file.api_hash }
  }
end