Class: Class

Inherits:
Object show all
Defined in:
lib/aws/s3/extensions.rb

Instance Method Summary collapse

Instance Method Details

#cattr_accessor(*syms) ⇒ Object


239
240
241
242
# File 'lib/aws/s3/extensions.rb', line 239

def cattr_accessor(*syms)
  cattr_reader(*syms)
  cattr_writer(*syms)
end

#cattr_reader(*syms) ⇒ Object


203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
# File 'lib/aws/s3/extensions.rb', line 203

def cattr_reader(*syms)
  syms.flatten.each do |sym|
    class_eval(<<-EOS, __FILE__, __LINE__)
      unless defined? @@#{sym}
        @@#{sym} = nil
      end

      def self.#{sym}
        @@#{sym}
      end

      def #{sym}
        @@#{sym}
      end
    EOS
  end
end

#cattr_writer(*syms) ⇒ Object


221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
# File 'lib/aws/s3/extensions.rb', line 221

def cattr_writer(*syms)
  syms.flatten.each do |sym|
    class_eval(<<-EOS, __FILE__, __LINE__)
      unless defined? @@#{sym}
        @@#{sym} = nil
      end

      def self.#{sym}=(obj)
        @@#{sym} = obj
      end

      def #{sym}=(obj)
        @@#{sym} = obj
      end
    EOS
  end
end