Sha256: 174c6fd519ef05a80faf2b7e5b4429437d7b018f889f2bce8e02799395c166dd

Contents?: true

Size: 532 Bytes

Versions: 6

Compression:

Stored size: 532 Bytes

Contents

#
# default values may be given either directly or as a block which will be
# evaluated in the context of self.  in both cases (value or block) the
# default is set only once and only if needed - it's a lazy evaluation.  the
# 'banger' method can be used to re-initialize a variable at any point whether
# or not it's already been initialized.
#
  require 'attributes'

  class C
    attribute :a => 42
    attribute(:b){ Float a }
  end

  c = C.new
  p c.a #=> 42
  p c.b #=> 42.0

  c.a = 43
  p c.a #=> 43
  c.a!
  p c.a #=> 42

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
attributes1-5.0.3 samples/b.rb
attributes1-5.0.2 samples/b.rb
attributes-5.0.1 samples/b.rb
attributes-5.0.0 samples/b.rb
attributes-4.1.0 samples/b.rb
attributes-4.0.0 samples/b.rb