133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
|
# File 'lib/classy-inheritance.rb', line 133
def depends_on(model_sym, options = {})
define_relationship(model_sym,options)
if options.has_key?(:validates_presence_if) && options[:validates_presence_if] != true
if [Symbol, String, Proc].include?(options[:validates_presence_if].class)
validates_presence_of model_sym, :if => options[:validates_presence_if]
end
else
validates_presence_of model_sym
end
if options.has_key?(:validates_associated_if) && options[:validates_associated_if] != true
if [Symbol, String, Proc].include?(options[:validates_associated_if].class)
validates_associated_dependent model_sym, options, :if => options[:validates_associated_if]
end
else
validates_associated_dependent model_sym, options
end
define_save_method(model_sym, options[:as]) unless options[:autosave]
define_find_with_method(model_sym)
if options[:as]
define_can_be_method_on_requisite_class(options[:class_name] || model_sym.to_s.classify, options[:as])
end
options[:attrs].each{|attr| define_accessors(model_sym, attr, options)}
end
|