Module: AppScrollsScrolls::Scrolls

Defined in:
lib/appscrolls/scrolls.rb

Constant Summary collapse

@@categories =
{}
@@list =
{}

Class Method Summary collapse

Class Method Details

.[](key) ⇒ Object



14
15
16
# File 'lib/appscrolls/scrolls.rb', line 14

def self.[](key)
  @@list[key.to_s]
end

.add(scroll) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/appscrolls/scrolls.rb', line 6

def self.add(scroll)
  AppScrollsScrolls::Scrolls.const_set ActiveSupport::Inflector.camelize(scroll.key.gsub("-", "_")), scroll
  @@list[scroll.key] = scroll
  (@@categories[scroll.category.to_s] ||= []) << scroll.key
  @@categories[scroll.category.to_s].uniq!
  scroll
end

.categoriesObject



26
27
28
# File 'lib/appscrolls/scrolls.rb', line 26

def self.categories
  @@categories.keys.sort
end

.for(category) ⇒ Object



30
31
32
# File 'lib/appscrolls/scrolls.rb', line 30

def self.for(category)
  (@@categories[category.to_s] || []).sort
end

.listObject



18
19
20
# File 'lib/appscrolls/scrolls.rb', line 18

def self.list
  @@list.keys.sort
end

.list_classesObject



22
23
24
# File 'lib/appscrolls/scrolls.rb', line 22

def self.list_classes
  @@list.values.sort_by{|c| c.key}
end

.remove_from_category(category, scroll) ⇒ Object



34
35
36
# File 'lib/appscrolls/scrolls.rb', line 34

def self.remove_from_category(category, scroll)
  (@@categories[category.to_s] ||= []).delete(scroll.key)
end