Module: Tarantool::ClassAttribute
- Included in:
- BaseRecord
- Defined in:
- lib/tarantool/core-ext.rb
Instance Method Summary collapse
-
#t_class_attribute(*attrs) ⇒ Object
spinoff from ActiveSupport class attribute.
Instance Method Details
#t_class_attribute(*attrs) ⇒ Object
spinoff from ActiveSupport class attribute
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/tarantool/core-ext.rb', line 6 def t_class_attribute(*attrs) attrs.each do |name| class_eval " def self.\#{name}() nil end\n def self.\#{name}?() !!\#{name} end\n\n def self.\#{name}=(val)\n singleton_class.class_eval do\n begin\n if method_defined?(:\"\#{name}\") || private_method_defined?(:\"\#{name}\")\n remove_method(:\#{name})\n end\n rescue NameError\n end\n define_method(:\#{name}) { val }\n end\n val\n end\n RUBY\n end\nend\n", __FILE__, __LINE__ + 1 |