Sha256: 19efa26e928313597307badeb52a22bd6be5f0c8fad83dc9b6183a2e960604a3

Contents?: true

Size: 751 Bytes

Versions: 6

Compression:

Stored size: 751 Bytes

Contents

require 'property_sets/property_set_model'
require 'property_sets/active_record_extension'
require 'property_sets/property_set_helper'

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

6 entries across 6 versions & 1 rubygems

Version Path
property_sets-0.0.11 lib/property_sets.rb
property_sets-0.0.10 lib/property_sets.rb
property_sets-0.0.9 lib/property_sets.rb
property_sets-0.0.8 lib/property_sets.rb
property_sets-0.0.7 lib/property_sets.rb
property_sets-0.0.6 lib/property_sets.rb