module AssignableValues::ActiveRecord
Private Instance Methods
Source
# File lib/assignable_values/active_record.rb, line 6 def assignable_values_for(property, options = {}, &values) restriction_type = if belongs_to_association?(property) Restriction::BelongsToAssociation elsif store_accessor_attribute?(property) Restriction::StoreAccessorAttribute else Restriction::ScalarAttribute end restriction_type.new(self, property, options, &values) end
Source
# File lib/assignable_values/active_record.rb, line 18 def belongs_to_association?(property) reflection = reflect_on_association(property) reflection && reflection.macro == :belongs_to end
Source
# File lib/assignable_values/active_record.rb, line 23 def store_accessor_attribute?(property) store_identifier_of(property).present? end
Source
# File lib/assignable_values/active_record.rb, line 27 def store_identifier_of(property) stored_attributes.find { |_, attrs| attrs.include?(property.to_sym) }&.first end