Module: Reactor::Attributes::ClassMethods
- Defined in:
- lib/reactor/attributes.rb
Instance Method Summary collapse
- #__cms_attributes(obj_class) ⇒ Object
- #__mandatory_cms_attributes(obj_class) ⇒ Object
- #inherited(subclass) ⇒ Object
- #reload_attributes(new_obj_class = nil) ⇒ Object
Instance Method Details
#__cms_attributes(obj_class) ⇒ Object
263 264 265 266 |
# File 'lib/reactor/attributes.rb', line 263 def __cms_attributes(obj_class) obj_class_def = RailsConnector::Meta::EagerLoader.instance.obj_class(obj_class) # RailsConnector::ObjClass.where(:obj_class_name => obj_class).first obj_class_def ? obj_class_def.custom_attributes : {} end |
#__mandatory_cms_attributes(obj_class) ⇒ Object
268 269 270 271 |
# File 'lib/reactor/attributes.rb', line 268 def __mandatory_cms_attributes(obj_class) obj_class_def = RailsConnector::Meta::EagerLoader.instance.obj_class(obj_class) # RailsConnector::ObjClass.where(:obj_class_name => obj_class).first obj_class_def ? obj_class_def.mandatory_attribute_names(only_custom_attributes: true) : [] end |
#inherited(subclass) ⇒ Object
254 255 256 257 258 259 260 261 |
# File 'lib/reactor/attributes.rb', line 254 def inherited(subclass) super(subclass) # if you remove this line, y'll get TypeError: can't dup NilClass at some point # t2 = Time.now Reactor::AttributeHandlers.install_attributes(subclass) # Rails.logger.debug "Installing dynamic module for #{subclass.name} took #{Time.now - t2}" subclass end |
#reload_attributes(new_obj_class = nil) ⇒ Object
273 274 275 276 277 278 279 280 281 282 |
# File 'lib/reactor/attributes.rb', line 273 def reload_attributes(new_obj_class = nil) new_obj_class ||= name if new_obj_class.nil? raise ArgumentError, "Cannot reload attributes because obj_class is unknown, provide one as a parameter" end RailsConnector::Meta::EagerLoader.instance.forget_obj_class(new_obj_class) Reactor::AttributeHandlers.reinstall_attributes(self, new_obj_class) reinitialize_attributes end |