Sha256: 8fa09ac687b16fb872ef86a313ab23a76d50002805c60f3d0f191a014417209f

Contents?: true

Size: 815 Bytes

Versions: 3

Compression:

Stored size: 815 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)
    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

3 entries across 3 versions & 1 rubygems

Version Path
property_sets-2.2.1 lib/property_sets.rb
property_sets-2.2.0 lib/property_sets.rb
property_sets-2.1.0 lib/property_sets.rb