Sha256: 68630b839566d5a92b9b8388fa7c8cc9b7b9cc05b89023062e7aa5a86ebe90c4

Contents?: true

Size: 344 Bytes

Versions: 7

Compression:

Stored size: 344 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.
#
  require 'attributes'

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

  c = C.new

  p c.a
  p c.b

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
attributes-3.0.0 samples/b.rb
attributes-3.5.0 samples/b.rb
attributes-3.0.1 samples/b.rb
attributes-3.7.0 samples/b.rb
attributes-3.2.0 samples/b.rb
attributes-3.3.0 samples/b.rb
attributes-3.6.0 samples/b.rb