Sha256: f6dbdc92540a4cb015a946315de428893c1ee5293c431be740d0de9eabf422d6

Contents?: true

Size: 816 Bytes

Versions: 3

Compression:

Stored size: 816 Bytes

Contents

require 'property_sets/property_set_model'
require 'property_sets/active_record_extension'
require 'property_sets/version'

begin
  require 'property_sets/action_view_extension'
rescue LoadError
end

module PropertySets
  def self.ensure_property_set_class(association, owner_class_name)
    const_name = "#{owner_class_name}#{association.to_s.singularize.camelcase}".to_sym

    unless Object.const_defined?(const_name)
      property_class = Class.new(ActiveRecord::Base) do
        include PropertySets::PropertySetModel::InstanceMethods
        extend  PropertySets::PropertySetModel::ClassMethods
      end

      Object.const_set(const_name, property_class)

      property_class.owner_class = owner_class_name
      property_class.owner_assoc = association
    end

    Object.const_get(const_name)
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
property_sets-3.8.0 lib/property_sets.rb
property_sets-3.7.1 lib/property_sets.rb
property_sets-3.7.0 lib/property_sets.rb