Sha256: 41cc7e0379be7c3a7c2da5c525c82c85b82ec86ad8e7ac733d5137bf3728a54e

Contents?: true

Size: 470 Bytes

Versions: 1

Compression:

Stored size: 470 Bytes

Contents

module FunkyAccessor
  def self.extended base
    class << base
      def funky_accessor *names
        names.each do |name|
          define_method(name) do |arg=nil, &block|
            if block
              instance_variable_set(:"@#{name}", block.call)
            elsif arg
              instance_variable_set(:"@#{name}", arg)
            else
              instance_variable_get(:"@#{name}")
            end
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
funky_accessor-0.0.1 lib/funky_accessor.rb