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 +4 -4
- data/README.md +7 -3
- data/app/models/forced/client.rb +15 -2
- data/app/models/forced/version.rb +14 -0
- data/lib/forced/version.rb +1 -1
- data/lib/forced/versionable.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 76cac05c0f8b27c3943c945919ee8ae18f23aefd
|
4
|
+
data.tar.gz: 6f4d0505a30b8e71abb11242e1258d377fa3c2ca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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
|
-
|
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
|
data/app/models/forced/client.rb
CHANGED
@@ -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'
|
data/lib/forced/version.rb
CHANGED
data/lib/forced/versionable.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2018-11-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|