Sha256: 6f52cac3bf8d880f6a0399b295e87be9971b461b0364b80fd679bf45da05c417

Contents?: true

Size: 753 Bytes

Versions: 20

Compression:

Stored size: 753 Bytes

Contents

require 'property_sets/property_set_model'
require 'property_sets/active_record_extension'
require 'property_sets/action_view_extension'

module PropertySets
  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
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
property_sets-0.5.5 lib/property_sets.rb
property_sets-0.5.4 lib/property_sets.rb
property_sets-0.5.3 lib/property_sets.rb
property_sets-0.5.2 lib/property_sets.rb
property_sets-0.5.1 lib/property_sets.rb
property_sets-0.5.0 lib/property_sets.rb
property_sets-0.4.4 lib/property_sets.rb
property_sets-0.4.3 lib/property_sets.rb
property_sets-0.4.2 lib/property_sets.rb
property_sets-0.4.1 lib/property_sets.rb
property_sets-0.4.0 lib/property_sets.rb
property_sets-0.3.6 lib/property_sets.rb
property_sets-0.3.5 lib/property_sets.rb
property_sets-0.3.4 lib/property_sets.rb
property_sets-0.3.3 lib/property_sets.rb
property_sets-0.3.2 lib/property_sets.rb
property_sets-0.3.0 lib/property_sets.rb
property_sets-0.2.0 lib/property_sets.rb
property_sets-0.1.2 lib/property_sets.rb
property_sets-0.1.1 lib/property_sets.rb