Sha256: bff4a55408879d771e16e854de3bf344083dd9ae72476db5c8c6bdfe4c272c4d

Contents?: true

Size: 433 Bytes

Versions: 1

Compression:

Stored size: 433 Bytes

Contents

module Rupture::Meta
  def meta
    @_meta ||= {}
  end

  def clone(meta = nil)
    meta ||= @_meta.clone if @_meta
    raise "meta must be of type Hash, it is #{meta.class}" unless meta.nil? or meta.kind_of?(Hash)
    copy = super()
    copy.instance_variable_set(:@_meta, meta)
    copy
  end

  def with_meta(meta)
    clone(meta)
  end

  def vary_meta(*args, &fn)
    fn ||= args.shift
    with_meta(fn[meta, *args])
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rupture-0.1.0 lib/rupture/meta.rb