Sha256: cca42d35dc8b778b8ad39e5c443e25e6266e191a03cce9df22e2a0e1a9ee4a24

Contents?: true

Size: 551 Bytes

Versions: 39

Compression:

Stored size: 551 Bytes

Contents

module AssignableValues
  module ActiveRecord

    private

    def assignable_values_for(property, options = {}, &values)
      restriction_type = belongs_to_association?(property) ? Restriction::BelongsToAssociation : Restriction::ScalarAttribute
      restriction_type.new(self, property, options, &values)
    end

    def belongs_to_association?(property)
      reflection = reflect_on_association(property)
      reflection && reflection.macro == :belongs_to
    end

  end
end

ActiveRecord::Base.send(:extend, AssignableValues::ActiveRecord)

Version data entries

39 entries across 39 versions & 1 rubygems

Version Path
assignable_values-1.0.0 lib/assignable_values/active_record.rb
assignable_values-0.18.1 lib/assignable_values/active_record.rb
assignable_values-0.18.0 lib/assignable_values/active_record.rb
assignable_values-0.17.0 lib/assignable_values/active_record.rb
assignable_values-0.16.6 lib/assignable_values/active_record.rb
assignable_values-0.16.5 lib/assignable_values/active_record.rb
assignable_values-0.16.4 lib/assignable_values/active_record.rb
assignable_values-0.16.3 lib/assignable_values/active_record.rb
assignable_values-0.16.2 lib/assignable_values/active_record.rb
assignable_values-0.16.1 lib/assignable_values/active_record.rb
assignable_values-0.16.0 lib/assignable_values/active_record.rb
assignable_values-0.15.1 lib/assignable_values/active_record.rb
assignable_values-0.15.0 lib/assignable_values/active_record.rb
assignable_values-0.14.0 lib/assignable_values/active_record.rb
assignable_values-0.13.2 lib/assignable_values/active_record.rb
assignable_values-0.13.1 lib/assignable_values/active_record.rb
assignable_values-0.13.0 lib/assignable_values/active_record.rb
assignable_values-0.12.1 lib/assignable_values/active_record.rb
assignable_values-0.12.0 lib/assignable_values/active_record.rb
assignable_values-0.11.3 lib/assignable_values/active_record.rb