Sha256: 79ba47a9f94a480efdbef7edb5aa041d879f630779df25b17cbacc6f39794a7c

Contents?: true

Size: 791 Bytes

Versions: 2

Compression:

Stored size: 791 Bytes

Contents

require 'version'

module At
  
  is_versioned
  
  class MethodToInstanceVariableProxy
    
    def initialize(parent)
      @parent = parent
    end
    
    def method_missing(meth, *args)
      @parent.instance_eval do
        
        if match = meth.to_s.match(/(.*)\=$/)
          value = args.length == 1 ? args.first : args
          instance_variable_set("@#{match[1]}", value)
        else
          if args.empty?
            instance_variable_get("@#{meth}")
          else
            value = args.length == 1 ? args.first : args
            instance_variable_set("@#{meth}", value)
          end
        end
        
      end
    end
    
  end
  
  def at
    @_method_to_instance_variable_proxy ||= MethodToInstanceVariableProxy.new(self)
  end
  
end

require 'at/import'

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
at-0.1.4 lib/at.rb
at-0.1.3 lib/at.rb