Permalink
Browse files

Add accessor method to create new context.

  • Loading branch information...
1 parent febbac9 commit 5199c10737432692133658f10f32f611c4e161c0 @vic committed Aug 26, 2011
Showing with 3 additions and 1 deletion.
  1. +3 −1 lib/akin/parser.rb
View
@@ -36,14 +36,16 @@ def ctx
class Context < Struct.new(:pos)
def self.attr(name, val = true)
- attr_accessor name
module_eval "
#{"def"} #{name}?
!!(@#{name} ||= #{val})
end
#{"def"} #{name}!
@#{name} = !#{name}?
end
+ #{"def"} #{name}=(val)
+ @#{name} = val
+ end
#{"def"} #{name}(val = #{val})
o = dup
o.#{name} = val

0 comments on commit 5199c10

Please sign in to comment.