lib/synchronisable/dsl/associations/association.rb in synchronisable-0.0.3 vs lib/synchronisable/dsl/associations/association.rb in synchronisable-0.0.4
- old
+ new
@@ -15,23 +15,24 @@
def create(synchronizer, name, options)
new(synchronizer, name).create(options)
end
end
- self.valid_options = %i(key class_name required)
+ self.valid_options = %i(key class_name required type)
- attr_reader :name, :model, :key, :required
+ attr_reader :name, :model, :key, :required, :type
def initialize(synchronizer, name)
@synchronizer, @name = synchronizer, name.to_sym
end
def create(options)
validate_options(options)
@key = options[:key]
@required = options[:required]
+ @type = options[:type]
if options[:class_name].present?
@model = options[:class_name].constantize
end
@@ -42,9 +43,11 @@
protected
def set_defaults
@required ||= false
+ @type ||= :ids
+
@model ||= @name.to_s.classify.constantize
@key = "#{@name}_#{self.class.key_suffix}" unless @key.present?
end
private