forest_liana 1.1.14 → 1.1.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9ed1df190068b491195f4ce6d96e3369a0597514
4
- data.tar.gz: 40ed3f6fade056c021539de67edc5bbd62b48f2d
3
+ metadata.gz: a9ddcb2a3b21734d0089682d98f29e6dba11c0e6
4
+ data.tar.gz: 9677980c020592ac28fc506941a192d495a3b29e
5
5
  SHA512:
6
- metadata.gz: 1d2c8bd8bb71665e3db8ecbe48864d5ab0a41bc3702abd1537c8cf0c6a02bae651624f320a68ca73eca0525a38fdbbd323936d82e5b216217cba4305871efb15
7
- data.tar.gz: f1d443cba25f22ad12d18f6430b78ad0266b720c6a4867eaf3cfbcc76cd1117bee2e65fd3f2fe5ea7949461e2b738cbe91360a53f1413eb2f8ae1612a5e7176c
6
+ metadata.gz: 69b1b1798846619b230ea7ddb610459b8accdbb04068c9de8cefb6d5bf5c2f3c8e5d2da9cc42868648209c481fe58bae2431cd276777da4a9061f277dffb1c8c
7
+ data.tar.gz: ddb0ac09089dcdf41758671d4b0e9e2a2777d42d64fe79f44f35d7a70fe12a907564ffa7888b77b7dac77770efb0376a03416a456e6b92eb56afac25356dfc2c
@@ -60,13 +60,18 @@ module ForestLiana
60
60
  end
61
61
 
62
62
  def relationship_related_link(attribute_name)
63
- ret = {
64
- href: "#{self_link}/#{format_name(attribute_name)}"
65
- }
63
+ ret = {}
66
64
 
67
65
  relationship_records = object.send(attribute_name)
68
66
  if relationship_records.respond_to?(:each)
69
- ret[:meta] = { count: relationship_records.count }
67
+
68
+ if Rails::VERSION::MAJOR == 4
69
+ ret[:meta] = { count: relationship_records.distinct.count }
70
+ else
71
+ ret[:meta] = {
72
+ count: relationship_records.count(:id, distinct: true)
73
+ }
74
+ end
70
75
  end
71
76
 
72
77
  ret
data/config/routes.rb CHANGED
@@ -15,7 +15,4 @@ ForestLiana::Engine.routes.draw do
15
15
  post ':collection' => 'resources#create'
16
16
  put ':collection/:id' => 'resources#update'
17
17
  delete ':collection/:id' => 'resources#destroy'
18
-
19
- # Associations
20
- get ':collection/:id/:association_name' => 'associations#index'
21
18
  end
@@ -1,3 +1,3 @@
1
1
  module ForestLiana
2
- VERSION = "1.1.14"
2
+ VERSION = "1.1.15"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: forest_liana
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.14
4
+ version: 1.1.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sandro Munda
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-10 00:00:00.000000000 Z
11
+ date: 2015-11-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -123,7 +123,6 @@ files:
123
123
  - app/assets/stylesheets/scaffold.css
124
124
  - app/controllers/forest_liana/apimaps_controller.rb
125
125
  - app/controllers/forest_liana/application_controller.rb
126
- - app/controllers/forest_liana/associations_controller.rb
127
126
  - app/controllers/forest_liana/resources_controller.rb
128
127
  - app/controllers/forest_liana/stats_controller.rb
129
128
  - app/controllers/forest_liana/stripe_controller.rb
@@ -1,53 +0,0 @@
1
- module ForestLiana
2
- class AssociationsController < ForestLiana::ApplicationController
3
-
4
- before_filter :find_resource
5
- before_filter :find_association
6
-
7
- def index
8
- getter = HasManyGetter.new(@resource, @association, params)
9
- getter.perform
10
-
11
- render json: serialize_models(getter.records,
12
- include: includes,
13
- count: getter.count,
14
- params: params)
15
- end
16
-
17
- private
18
-
19
- def find_resource
20
- @resource = SchemaUtils.find_model_from_table_name(params[:collection])
21
-
22
- if @resource.nil? || !@resource.ancestors.include?(ActiveRecord::Base)
23
- render json: {status: 404}, status: :not_found
24
- end
25
- end
26
-
27
- def find_association
28
- @association = @resource.reflect_on_association(
29
- params[:association_name])
30
-
31
- # Only accept "many" associations
32
- if @association.nil? ||
33
- [:belongs_to, :has_one].include?(@association.macro)
34
- render json: {status: 404}, status: :not_found
35
- end
36
- end
37
-
38
- def resource_params
39
- ResourceDeserializer.new(@resource, params[:resource]).perform
40
- end
41
-
42
- def includes
43
- @association.klass
44
- .reflect_on_all_associations
45
- .select do |a|
46
- [:belongs_to, :has_and_belongs_to_many].include?(a.macro) &&
47
- !a.options[:polymorphic]
48
- end
49
- .map {|a| a.name.to_s }
50
- end
51
-
52
- end
53
- end