forced 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0f8bfe65c4245d7193e813ab666edea94a8d9bc4
4
- data.tar.gz: 95c773c3051dee62f912d14cf00e6e6ca7628aa5
3
+ metadata.gz: 76cac05c0f8b27c3943c945919ee8ae18f23aefd
4
+ data.tar.gz: 6f4d0505a30b8e71abb11242e1258d377fa3c2ca
5
5
  SHA512:
6
- metadata.gz: 1f10f544891d22c7b6c9f3eded67de2f93a87a0de60f87a9a908f39d5da7f5aade90af1a51e46f302b1e7777db21f9386d089018b2f2bfc252f75ce80b7dbcae
7
- data.tar.gz: ef0fafa3cb75e9815fbc5291e118ff9254270f5b2cd038f7094c0df6a0a59c0827c90adfccde9ddf55e592a44a7bc488252304a400dead669c88a0f7d827530c
6
+ metadata.gz: 63649e90d0f3262dc6ed06fdec79c208ebfe2bc1849480f12341e865aad377e6b6f8dfd05338669fec9354d55ca33329f17ccb4307c1de5013e5617d0c2b40ce
7
+ data.tar.gz: f02603de3a7ad0127af3f15fda5380230f0e7acd0a3297755c12ff17fa3ccc0679b1c3a6fce2cc4b1258ee520af1e85870cf88503d7ee897f6a0371f12850f65
data/README.md CHANGED
@@ -42,14 +42,18 @@ You endpoint and tables are set!
42
42
 
43
43
  ## Usage
44
44
 
45
- Add `is_versionable` to any model you want to keep as a parent for `Forced::Client` model.
45
+ If you want a parent for your `Forced::Client` records, you can add the desired parent model `is_versionable`. Beware that both `Forced::Client` to `Forced::Version` relation and `is_versionable` to `Forced::Client` relation are set to `dependent: :destroy`.
46
46
 
47
- For example, imagine you have a `Brand` model to identify each application. Adding the line below to your model, will hold a relation for `has_many :clients'
47
+ The `Forced::Client`'s polymorphic relation is optional as well. So, you can use the gem without setting a parent class relation. It'll work exactly the same.
48
+
49
+ For example, imagine you have a `Brand` model to identify each application. Adding the line below to your model, will hold a relation for `has_many :clients`
48
50
 
49
51
  ```ruby
50
52
  class Brand < ApplicationRecord
51
53
  # ...
52
54
 
55
+ # If you haven't read the above paragraph, please do.
56
+ # This is optional.
53
57
  is_versionable
54
58
 
55
59
  # ...
@@ -87,7 +91,7 @@ If you want to return some version of this hash, you can access the response by
87
91
  response = Forced::Response.call(request)
88
92
  ```
89
93
 
90
- To create a record, you can use your Rails console. `Forced::Client`
94
+ To create a record, you can use your Rails console. `Forced::Client` is polymorphic and keeps `foreign_key` and `foreign_type` columns as `item_#`. So, when you are creating a `Forced::Client` instance, use `item:` for your reference column, e.g. `Forced::Client.create(item: Brand.first)`
91
95
 
92
96
  ```ruby
93
97
  Forced::Client.new
@@ -1,7 +1,20 @@
1
+ # == Schema Information
2
+ #
3
+ # Table name: forced_clients
4
+ #
5
+ # id :integer not null, primary key
6
+ # item_type :string
7
+ # item_id :integer
8
+ # identifier :string
9
+ # deleted_at :datetime
10
+ # created_at :datetime not null
11
+ # updated_at :datetime not null
12
+ #
13
+
1
14
  module Forced
2
15
  class Client < ApplicationRecord
3
- belongs_to :item, polymorphic: true
16
+ belongs_to :item, polymorphic: true, optional: true
4
17
 
5
- has_many :versions, class_name: 'Forced::Version', foreign_key: 'client_id'
18
+ has_many :versions, class_name: 'Forced::Version', foreign_key: 'client_id', dependent: :destroy
6
19
  end
7
20
  end
@@ -1,3 +1,17 @@
1
+ # == Schema Information
2
+ #
3
+ # Table name: forced_versions
4
+ #
5
+ # id :integer not null, primary key
6
+ # client_id :integer
7
+ # version :string(255)
8
+ # force_update :boolean default(FALSE)
9
+ # changelog :text
10
+ # deleted_at :datetime
11
+ # created_at :datetime not null
12
+ # updated_at :datetime not null
13
+ #
14
+
1
15
  module Forced
2
16
  class Version < ApplicationRecord
3
17
  belongs_to :client, class_name: 'Forced::Client'
@@ -1,6 +1,6 @@
1
1
  module Forced
2
2
  MAJOR = 1
3
- MINOR = 0
3
+ MINOR = 1
4
4
  TINY = 0
5
5
  PRE = nil
6
6
 
@@ -3,7 +3,7 @@ module Forced
3
3
  extend ActiveSupport::Concern
4
4
 
5
5
  included do
6
- has_many :clients, class_name: 'Forced::Client', as: :item
6
+ has_many :clients, class_name: 'Forced::Client', as: :item, dependent: :destroy
7
7
  end
8
8
  end
9
9
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: forced
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - aoozdemir
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-11-05 00:00:00.000000000 Z
11
+ date: 2018-11-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails