14
15
16
17
18
19
20
21
22
23
|
# File 'lib/daisybill_api/ext/associations.rb', line 14
def has_many(name, options = {})
clazz = modulize options[:class]
define_method name do |params = {}|
params.merge!(:"#{self.class.singular_key}_id" => self.id)
params.merge!(path: "#{show_path}/#{name}") if options[:set_path]
params.merge!(path: clazz.constantize.index_path(id)) if options[:set_path] && options[:use_path_prefix]
params.merge!(collection_key: options[:collection_key]) if options[:collection_key]
clazz.constantize.all(params)
end
end
|