Class: Simple::Service::Context

Inherits:
Object
  • Object
show all
Defined in:
lib/simple/service/context.rb

Defined Under Namespace

Classes: ReadOnlyError

Instance Method Summary collapse

Constructor Details

#initializeContext

Returns a new instance of Context.



9
10
11
# File 'lib/simple/service/context.rb', line 9

def initialize
  @hsh = {}
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(sym, *args, &block) ⇒ Object (private)



33
34
35
36
37
38
39
40
41
42
43
# File 'lib/simple/service/context.rb', line 33

def method_missing(sym, *args, &block)
  if block
    super
  elsif args.count == 0 && sym =~ IDENTIFIER_REGEXP
    self[sym]
  elsif args.count == 1 && sym =~ ASSIGNMENT_REGEXP
    self[$1.to_sym] = args.first
  else
    super
  end
end