48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
# File 'lib/mongo/model/assignment.rb', line 48
def assign *args, &block
if block
dsl = ::Mongo::Model::Assignment::Dsl.new self
dsl.instance_eval &block
else
args.size.must.be_in 2..3
attr_name = args.shift
attr_name.must.be_a Symbol
if args.first.is_a? Class
type, mass_assignment = args
mass_assignment ||= false
type.must.respond_to :cast
else
type, mass_assignment = nil, args.first
end
self._assign ||= {}
_assign[attr_name] = [type, mass_assignment]
end
end
|