Class: Engine2::Schemes
- Defined in:
- lib/engine2/scheme.rb,
lib/engine2/action/array.rb
Instance Attribute Summary collapse
-
#builtin ⇒ Object
readonly
Returns the value of attribute builtin.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Instance Method Summary collapse
- #[](name, raise = true) ⇒ Object
- #define_scheme(name, &blk) ⇒ Object
-
#initialize ⇒ Schemes
constructor
A new instance of Schemes.
Constructor Details
#initialize ⇒ Schemes
Returns a new instance of Schemes.
14 15 16 17 |
# File 'lib/engine2/scheme.rb', line 14 def initialize @builtin = {} @user = {} end |
Instance Attribute Details
#builtin ⇒ Object (readonly)
Returns the value of attribute builtin.
13 14 15 |
# File 'lib/engine2/scheme.rb', line 13 def builtin @builtin end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
13 14 15 |
# File 'lib/engine2/scheme.rb', line 13 def user @user end |
Instance Method Details
#[](name, raise = true) ⇒ Object
25 26 27 28 29 |
# File 'lib/engine2/scheme.rb', line 25 def [] name, raise = true scheme = @builtin[name] || @user[name] raise E2Error.new("Scheme #{name} not found") if !scheme && raise scheme end |
#define_scheme(name, &blk) ⇒ Object
19 20 21 22 23 |
# File 'lib/engine2/scheme.rb', line 19 def define_scheme name, &blk schemes = Engine2::core_loaded ? @user : @builtin raise E2Error.new("Scheme '#{name}' already defined") if schemes[name] schemes[name] = blk end |