Sha256: 8fcfa55a2abb07da9b93c97a0b12dd18f2d8242d5fcdc086532c2e97fded1bfb

Contents?: true

Size: 437 Bytes

Versions: 11

Compression:

Stored size: 437 Bytes

Contents

# encoding: UTF-8

module BetterAttrAccessor
  def better_attr_reader(*names)
    names.each do |name|
      attr_reader name
      # leaves nil and false as is, returns true for everything else
      class_eval <<-RUBY
        def #{name}?
          @#{name} && true
        end
      RUBY
    end
  end

  def better_attr_accessor(*names)
    better_attr_reader *names
    names.each do |name|
      attr_writer name
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
tms-1.7.4 lib/tms/better_attr_accessor.rb
tms-1.7.3 lib/tms/better_attr_accessor.rb
tms-1.7.2 lib/tms/better_attr_accessor.rb
tms-1.7.1 lib/tms/better_attr_accessor.rb
tms-1.7.0 lib/tms/better_attr_accessor.rb
tms-1.6.0 lib/tms/better_attr_accessor.rb
tms-1.5.0 lib/tms/better_attr_accessor.rb
tms-1.4.2 lib/tms/better_attr_accessor.rb
tms-1.4.0 lib/tms/better_attr_accessor.rb
tms-1.3.5 lib/tms/better_attr_accessor.rb
tms-1.3.4 lib/tms/better_attr_accessor.rb