Module: Hippo::Screen

Extended by:
Enumerable
Defined in:
lib/hippo/screen.rb,
lib/hippo/screen/group.rb,
lib/hippo/screen/definition.rb

Defined Under Namespace

Classes: Definition, DefinitionList, Group

Constant Summary collapse

GROUPS =
Hash.new{|h,k| g=Group.new; g.identifier=k; h[k]=g }
DEFINITIONS =
Hash.new
EXTENSIONS =
Hash.new

Class Method Summary collapse

Class Method Details

.[](config) ⇒ Object


49
50
51
52
53
54
55
# File 'lib/hippo/screen.rb', line 49

def [](config)
    if DEFINITIONS.key?(config)
        DEFINITIONS[config]
    else
        nil
    end
end

.config_fileObject


84
85
86
# File 'lib/hippo/screen.rb', line 84

def config_file
    Hippo::Extensions.controlling.root_path.join("config", "screens.rb")
end

.define_group(id) {|group| ... } ⇒ Object

Yields:

  • (group)

67
68
69
70
# File 'lib/hippo/screen.rb', line 67

def define_group(id)
    group = GROUPS[id]
    yield group
end

.eachObject


57
58
59
# File 'lib/hippo/screen.rb', line 57

def each
    DEFINITIONS.values.each { |s| yield s }
end

.each_groupObject


79
80
81
82
# File 'lib/hippo/screen.rb', line 79

def each_group
    Extensions.load_screens
    GROUPS.values.each{ | group | yield group }
end

.for_extension(id) {|definition| ... } ⇒ Object

Yields:

  • (definition)

61
62
63
64
65
# File 'lib/hippo/screen.rb', line 61

def for_extension(id)
    definition = EXTENSIONS[id] ||= DefinitionList.new(id)
    yield definition if block_given?
    definition
end

.ids_for_user(user) ⇒ Object


72
73
74
75
76
77
# File 'lib/hippo/screen.rb', line 72

def ids_for_user(user)
    Extensions.load_screens
    for_extension(Hippo::Extensions.controlling.identifier).select{|s|
        s.viewable_by?(user)
    }.map(&:identifier)
end