Module: PropertySets
- Defined in:
- lib/property_sets.rb,
lib/property_sets/property_set_model.rb,
lib/property_sets/active_record_extension.rb
Defined Under Namespace
Modules: ActiveRecordExtension, PropertySetModel
Class Method Summary collapse
Class Method Details
.ensure_property_set_class(association, owner_class) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/property_sets.rb', line 6 def self.ensure_property_set_class(association, owner_class) const_name = "#{owner_class.name}#{association.to_s.singularize.capitalize}".to_sym unless Object.const_defined?(const_name) property_class = Object.const_set(const_name, Class.new(ActiveRecord::Base)) property_class.class_eval do include PropertySets::PropertySetModel::InstanceMethods extend PropertySets::PropertySetModel::ClassMethods end property_class.owner_class = owner_class property_class.owner_assoc = association end Object.const_get(const_name) end |