Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Clean up the configuration interface so the underlying data structure…
… is no longer exposed.
- Loading branch information
1 parent
8befd09
commit 8c2a99a
Showing
3 changed files
with
36 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,42 @@ | ||
# encoding: UTF-8 | ||
|
||
require 'singleton' | ||
|
||
module Watchmaker | ||
|
||
# Singleton configuration class to hold all configured information. | ||
# | ||
class Configuration | ||
|
||
include Singleton | ||
|
||
# Store list of all profiles. | ||
# | ||
attr_accessor :profiles | ||
end | ||
|
||
# As soon as we define the singleton configuration class, instantitate | ||
# it and default some values. | ||
# | ||
Configuration.instance.tap do |o| | ||
o.profiles = {} | ||
# Initialize to an empty hash. | ||
# | ||
def initialize | ||
@profiles = {} | ||
end | ||
|
||
def self.learn(name, dependencies, &block) | ||
instance.learn(name, dependencies, &block) | ||
end | ||
|
||
def self.learned(name) | ||
instance.learned(name) | ||
end | ||
|
||
def learn(name, dependencies, &block) | ||
@profiles[name] = { | ||
:dependencies => dependencies, | ||
:block => block | ||
} | ||
end | ||
|
||
def learned(name) | ||
@profiles[name] | ||
end | ||
|
||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters