Class: Dramatis::Runtime::Gate::Hash
- Inherits:
-
Object
- Object
- Dramatis::Runtime::Gate::Hash
- Defined in:
- lib/dramatis/runtime/gate.rb
Instance Method Summary collapse
- #accept(*args) ⇒ Object
- #accepts?(*args) ⇒ Boolean
- #always(*args) ⇒ Object
- #default(*args) ⇒ Object
-
#initialize(default, hash = {}) ⇒ Hash
constructor
A new instance of Hash.
- #refuse(*args) ⇒ Object
- #set_default(value, *args) ⇒ Object
- #track ⇒ Object
Constructor Details
#initialize(default, hash = {}) ⇒ Hash
Returns a new instance of Hash.
181 182 183 184 185 186 187 188 |
# File 'lib/dramatis/runtime/gate.rb', line 181 def initialize default, hash = {} @default = default @hash = hash.clone @queued = {} track and warn "create default = #{@default} hash = [#{@hash.keys.join(' ')}]" @always = [] @call_thread = nil end |
Instance Method Details
#accept(*args) ⇒ Object
206 207 208 209 210 211 212 213 |
# File 'lib/dramatis/runtime/gate.rb', line 206 def accept *args track and warn "accept [#{args.join(' ')}]" if args.length == 1 @hash[args[0]] = ACCEPT else @hash[args[0]].accept( *args[1,args.length] ) end end |
#accepts?(*args) ⇒ Boolean
233 234 235 236 237 238 239 240 |
# File 'lib/dramatis/runtime/gate.rb', line 233 def accepts? *args v = nil if v == nil v = @hash.has_key?( args[0] ) ? @hash[args[0]].accepts?( *args[1,args.length] ) : @default end track and warn "accepts? [#{args.join(' ')}] => #{v}" v end |
#always(*args) ⇒ Object
192 193 194 195 |
# File 'lib/dramatis/runtime/gate.rb', line 192 def always *args track and warn "always [#{args.join(' ')}]" @always << args end |
#default(*args) ⇒ Object
215 216 217 218 219 220 221 222 |
# File 'lib/dramatis/runtime/gate.rb', line 215 def default *args track and warn "default [#{args.join(' ')}]" if args.length == 1 @hash.delete args[0] else @hash[args[0]].default( *args[1,args.length] ) end end |
#refuse(*args) ⇒ Object
197 198 199 200 201 202 203 204 |
# File 'lib/dramatis/runtime/gate.rb', line 197 def refuse *args track and warn "refuse [#{args.join(' ')}]" if args.length == 1 @hash[args[0]] = REJECT else @hash[args[0]].refuse( *args[1,args.length] ) end end |
#set_default(value, *args) ⇒ Object
224 225 226 227 228 229 230 231 |
# File 'lib/dramatis/runtime/gate.rb', line 224 def set_default value, *args track and warn "default = #{value} [#{args.join(' ')}] #{args.length}" if args.length == 0 @default = value else @hash[args[0]].set_default value, *args[1,args.length] end end |
#track ⇒ Object
190 |
# File 'lib/dramatis/runtime/gate.rb', line 190 def track; false; end |