Module: Rupture::Meta

Defined in:
lib/rupture/meta.rb

Instance Method Summary collapse

Instance Method Details

#clone(meta = nil) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/rupture/meta.rb', line 6

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) or meta.kind_of?(Rupture::HashMap)
  copy = super()
  copy.instance_variable_set(:@_meta, meta)
  copy
end

#metaObject



2
3
4
# File 'lib/rupture/meta.rb', line 2

def meta
  @_meta ||= {}
end

#vary_meta(*args, &fn) ⇒ Object



18
19
20
21
# File 'lib/rupture/meta.rb', line 18

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

#with_meta(meta) ⇒ Object



14
15
16
# File 'lib/rupture/meta.rb', line 14

def with_meta(meta)
  clone(meta)
end