Sha256: 388d1b40e064cefc95d665647ee44182ced1dfaaffb97b9f49098aed67b95bb6

Contents?: true

Size: 711 Bytes

Versions: 47

Compression:

Stored size: 711 Bytes

Contents

class Object
  # Works similar as <code>attr_accessor</code> only reader method is changed
  # to allow to set value (used for Lolita blocks in different classes).
  # ====Example
  #     class Klass
  #       lolita_accessor :my_method
  #     end
  #     k=Klass.new
  #     k.my_method("it's me")
  #     puts k.my_method #=> it's me
  def lolita_accessor *methods
    if [Class,Module].include?(self.class)
      methods.each do |method|
        class_eval <<-ACCESSORS,__FILE__,__LINE__+1
        def #{method}(value=nil)
          @#{method}=value if value
          @#{method}
        end

        def #{method}=(value)
          @#{method}=value
        end
        ACCESSORS
      end
    end
  end
end

Version data entries

47 entries across 47 versions & 1 rubygems

Version Path
lolita-4.0.11 lib/lolita/ruby_ext/accessors.rb
lolita-4.2.0 lib/lolita/ruby_ext/accessors.rb
lolita-4.0.10 lib/lolita/ruby_ext/accessors.rb
lolita-4.0.9 lib/lolita/ruby_ext/accessors.rb
lolita-4.0.8 lib/lolita/ruby_ext/accessors.rb
lolita-4.0.6 lib/lolita/ruby_ext/accessors.rb
lolita-3.4.3 lib/lolita/ruby_ext/accessors.rb
lolita-3.3.7 lib/lolita/ruby_ext/accessors.rb
lolita-3.3.5 lib/lolita/ruby_ext/accessors.rb
lolita-3.2.0.rc.17 lib/lolita/ruby_ext/accessors.rb
lolita-3.2.0.rc.16 lib/lolita/ruby_ext/accessors.rb
lolita-3.2.0.rc.14 lib/lolita/ruby_ext/accessors.rb
lolita-3.2.0.rc.13 lib/lolita/ruby_ext/accessors.rb
lolita-3.2.0.rc.12 lib/lolita/ruby_ext/accessors.rb
lolita-3.2.0.rc.11 lib/lolita/ruby_ext/accessors.rb
lolita-3.2.0.rc.10 lib/lolita/ruby_ext/accessors.rb
lolita-3.2.0.rc.9 lib/lolita/ruby_ext/accessors.rb
lolita-3.2.0.rc.7 lib/lolita/ruby_ext/accessors.rb
lolita-3.1.18 lib/lolita/ruby_ext/accessors.rb
lolita-3.2.0.rc.6 lib/lolita/ruby_ext/accessors.rb