Class: Reactor::AttributeHandlers
- Inherits:
-
Object
- Object
- Reactor::AttributeHandlers
- Includes:
- Singleton
- Defined in:
- lib/reactor/attributes_handlers.rb
Class Method Summary collapse
-
.install_attributes(klass) ⇒ Object
Use this method to install attributes into class.
- .obj_class(klass) ⇒ Object
-
.reinstall_attributes(klass, obj_class) ⇒ Object
Use this method if attributes changed and you wish to reinstall them.
Instance Method Summary collapse
-
#initialize ⇒ AttributeHandlers
constructor
A new instance of AttributeHandlers.
- #install(klass, obj_class) ⇒ Object
- #regenerate_attribute_handler(obj_class_name) ⇒ Object
Constructor Details
#initialize ⇒ AttributeHandlers
Returns a new instance of AttributeHandlers.
13 14 15 16 17 |
# File 'lib/reactor/attributes_handlers.rb', line 13 def initialize # t1 = Time.now generate_attribute_handlers # Rails.logger.debug "Reactor::AttributeHandlers: generate_attribute_handlers took #{Time.now - t1}" end |
Class Method Details
.install_attributes(klass) ⇒ Object
Use this method to install attributes into class
20 21 22 |
# File 'lib/reactor/attributes_handlers.rb', line 20 def self.install_attributes(klass) Reactor::AttributeHandlers.instance.install(klass, obj_class(klass)) end |
.obj_class(klass) ⇒ Object
32 33 34 |
# File 'lib/reactor/attributes_handlers.rb', line 32 def self.obj_class(klass) klass.name.split("::").last end |
.reinstall_attributes(klass, obj_class) ⇒ Object
Use this method if attributes changed and you wish to reinstall them
25 26 27 28 29 30 |
# File 'lib/reactor/attributes_handlers.rb', line 25 def self.reinstall_attributes(klass, obj_class) Reactor::AttributeHandlers.instance.tap do |handler| handler.regenerate_attribute_handler(obj_class) handler.install(klass, obj_class) end end |
Instance Method Details
#install(klass, obj_class) ⇒ Object
36 37 38 |
# File 'lib/reactor/attributes_handlers.rb', line 36 def install(klass, obj_class) klass.send(:include, handler_module(obj_class)) if obj_class_known?(obj_class) end |
#regenerate_attribute_handler(obj_class_name) ⇒ Object
40 41 42 |
# File 'lib/reactor/attributes_handlers.rb', line 40 def regenerate_attribute_handler(obj_class_name) generate_attribute_handler(RailsConnector::Meta::EagerLoader.instance.obj_class(obj_class_name)) end |