Sha256: 2a955e77aeea29b49c49491ad0bf0cf81ea97af81276ae222454b0f8759f4df8
Contents?: true
Size: 1.05 KB
Versions: 1
Compression:
Stored size: 1.05 KB
Contents
require 'pathname' require 'active_support/concern' module At extend ActiveSupport::Concern VERSION ||= Pathname.new(__FILE__).dirname.join('..', 'VERSION').read class MethodToInstanceVariableProxy def initialize(parent) @parent = parent end def method_missing(meth, *args, &blk) @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 block_given? instance_variable_set("@#{meth}", args.empty? ? args : blk.call) 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 end module InstanceMethods def at @_method_to_instance_variable_proxy ||= MethodToInstanceVariableProxy.new(self) end end end require 'at/core_ext'
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
at-0.1.2 | lib/at.rb |