Module: ThinkingSphinx::ClassAttributeMethods
- Defined in:
- lib/thinking_sphinx/rails_additions.rb
Instance Method Summary collapse
Instance Method Details
#cattr_accessor(*syms) ⇒ Object
127 128 129 130 |
# File 'lib/thinking_sphinx/rails_additions.rb', line 127 def cattr_accessor(*syms) cattr_reader(*syms) cattr_writer(*syms) end |
#cattr_reader(*syms) ⇒ Object
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/thinking_sphinx/rails_additions.rb', line 87 def cattr_reader(*syms) syms.flatten.each do |sym| next if sym.is_a?(Hash) 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
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
# File 'lib/thinking_sphinx/rails_additions.rb', line 106 def cattr_writer(*syms) = 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 " unless [:instance_writer] == false } EOS end end |