Class: Otaku::Handler::Context
- Inherits:
-
Object
- Object
- Otaku::Handler::Context
- Defined in:
- lib/otaku/handler/context.rb
Overview
:nodoc:
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
Returns the value of attribute code.
Instance Method Summary collapse
- #eval! ⇒ Object
-
#initialize(methods_hash) ⇒ Context
constructor
A new instance of Context.
- #marshal_dump ⇒ Object
- #marshal_load(data) ⇒ Object
Constructor Details
#initialize(methods_hash) ⇒ Context
Returns a new instance of Context.
7 8 9 10 11 12 |
# File 'lib/otaku/handler/context.rb', line 7 def initialize(methods_hash) @code = 'Class.new{ %s }.new' % methods_hash.map do |method, val| 'def %s; %s; end' % [method, method_body(val)] end.sort.join('; ') end |
Instance Attribute Details
#code ⇒ Object (readonly)
Returns the value of attribute code.
5 6 7 |
# File 'lib/otaku/handler/context.rb', line 5 def code @code end |
Instance Method Details
#eval! ⇒ Object
14 15 16 |
# File 'lib/otaku/handler/context.rb', line 14 def eval! eval(@code, nil, '(generated class)', 1) end |
#marshal_dump ⇒ Object
18 19 20 |
# File 'lib/otaku/handler/context.rb', line 18 def marshal_dump [@code] end |
#marshal_load(data) ⇒ Object
22 23 24 |
# File 'lib/otaku/handler/context.rb', line 22 def marshal_load(data) @code, _ = data end |