Module: Toss::Meta::InstanceMethods

Defined in:
lib/toss/meta.rb

Instance Method Summary collapse

Instance Method Details

#create_accessor(name) ⇒ Object



16
17
18
19
20
21
22
23
24
25
# File 'lib/toss/meta.rb', line 16

def create_accessor(name)
  create_method("#{name}=") do |value| 
    $globals =  $globals || {}
    $globals[name] = value
  end
  create_method(name.to_sym) do 
    $globals =  $globals || {}
    $globals[name]
  end
end

#create_method(name, &block) ⇒ Object



12
13
14
# File 'lib/toss/meta.rb', line 12

def create_method(name, &block)
  Object.send(:define_method, name, &block)
end

#set(name, value) ⇒ Object



7
8
9
10
# File 'lib/toss/meta.rb', line 7

def set(name, value)
  create_accessor(name)
  Object.send("#{name}=", value)
end