Sha256: 89f77e3e4375a9194460bcdbcfe07e066da3751a40282e4cdd73e41f9876a3b1

Contents?: true

Size: 379 Bytes

Versions: 2

Compression:

Stored size: 379 Bytes

Contents

class Object
  def linkable_attr(attr_sym)
    attr_reader attr_sym
    define_method("#{attr_sym}=") do |val|
      instance_variable_set("@#{attr_sym}", val)
      if val.respond_to? :call
        meta_def attr_sym do
          val.call
        end
      else
        meta_def attr_sym do
          val
        end
      end
    end
  end

  def L(&block)
    block
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ruck-0.1.2 lib/ruck/misc/linkage.rb
ruck-0.1.0 lib/ruck/misc/linkage.rb