Skip to content

Commit

Permalink
Merge pull request #3 from rhec/develop
Browse files Browse the repository at this point in the history
loosen dependencies
  • Loading branch information
rhec authored Feb 8, 2018
2 parents e6c3b90 + 959ca49 commit aec062f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
24 changes: 14 additions & 10 deletions lib/restpack_serializer/serializable/side_load_data_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,21 @@ def side_load_belongs_to
def side_load_has_many
has_association_relation do |options|
options.context[:singular] = false
# add dynamic filters from @root_options
extra_scope = @root_options.context.fetch(:"#{@association.name}_association_scope", nil)
if extra_scope
options.scope = options.scope.where(extra_scope)
end
if join_table = @association.options[:through]
options.scope = options.scope.joins(join_table).distinct
association_fk = @association.through_reflection.foreign_key.to_sym
options.filters = { join_table => { association_fk => model_ids } }
if @root_options.context.has_key?(:"#{@association.name}_association_values")
options.scope = @root_options.context[:"#{@association.name}_association_values"]
else
options.filters = { @association.foreign_key.to_sym => model_ids }
# add dynamic filters from @root_options
extra_scope = @root_options.context.fetch(:"#{@association.name}_association_scope", nil)
if extra_scope
options.scope = options.scope.where(extra_scope)
end
if join_table = @association.options[:through]
options.scope = options.scope.joins(join_table).distinct
association_fk = @association.through_reflection.foreign_key.to_sym
options.filters = { join_table => { association_fk => model_ids } }
else
options.filters = { @association.foreign_key.to_sym => model_ids }
end
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions restpack_serializer.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ Gem::Specification.new do |gem|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
gem.require_paths = ["lib"]

gem.add_dependency 'activesupport', ['>= 4.0.3', '< 5.0']
gem.add_dependency 'activerecord', ['>= 4.0.3', '< 5.0']
gem.add_dependency 'activesupport', ['>= 4.0.3']
gem.add_dependency 'activerecord', ['>= 4.0.3']
gem.add_dependency 'kaminari', '~> 0.16.1'

gem.add_development_dependency 'restpack_gem', '~> 0.0.9'
Expand Down

0 comments on commit aec062f

Please sign in to comment.