forced 1.1.1 → 1.2.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: 15dfa1cdf12965aa435d5a421e2e02feefc72bdd
4
- data.tar.gz: e923d04a3b5c36f1b15d4a7e78ad162cb6b45bb9
3
+ metadata.gz: 16c4c3bfcdfca6854aff43e3155e3e34102b36dc
4
+ data.tar.gz: a1157c7f545af0f270bf9a7c669f929884c82552
5
5
  SHA512:
6
- metadata.gz: 79a13fc074436dc5f2ab88fab77258438dfd9aa5f07e516da6cecc61a44d8da0edb52a941d4caa5eeb68f70fc88118625000bcc237ec08fe32cc73921591dd5d
7
- data.tar.gz: 2be9b20179a649fe225f0c4a16b92dd15dc7c7c63e6fb2eb03f777f54f2fd2101eabc04c993192d7870f3f82d4a146610c24e6ee3bc4385fda72b3148c00e6a6
6
+ metadata.gz: 64b4a7a5081e2288eb4019eb5e83e14a94eab16d52147a5fe5b07871006e93fe089efa382f8bb5d4b45a89865cda3903f03217c34414cb1de5263a2a5c76b233
7
+ data.tar.gz: 8d1fbe32b4928fcff4d93c12c4092b1a7589413125e935aa3e96256f8f888fdca53f1f11d88c08c8703cf8b2c89e6e0ed3bf0e85d2e07f486f5869bdf4c8ed01
data/README.md CHANGED
@@ -42,7 +42,7 @@ You endpoint and tables are set!
42
42
 
43
43
  ## Usage
44
44
 
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`.
45
+ If you want a parent for your `Forced::Client` records, you can add `is_versionable` to the desired parent model. 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
48
 
@@ -67,7 +67,7 @@ Brand.find(:id).clients
67
67
  # => #<ActiveRecord::Associations::CollectionProxy [...]>
68
68
 
69
69
  Brand.find(:id).clients.to_sql
70
- # => "SELECT \"forced_clients\".* FROM \"forced_clients\" WHERE \"forced_clients\".\"item_id\" = :id AND \"forced_clients\".\"item_type\" = 'Brand'"
70
+ # => "SELECT "forced_clients".* FROM "forced_clients" WHERE "forced_clients"."owner_id" = :id AND "forced_clients"."owner_type" = 'Brand'"
71
71
  ```
72
72
 
73
73
  The Forced module needs to get the coming request to prepare the response. As long as request headers contains `X-Platform` and `X-Client-Version`, you are good to go.
@@ -91,11 +91,31 @@ If you want to return some version of this hash, you can access the response by
91
91
  response = Forced::Response.call(request)
92
92
  ```
93
93
 
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)`
94
+ To change the default response from the mounted endpoint, create a `StatusController` like below.
95
+
96
+ ```ruby
97
+ # In order this to work,
98
+ # you need to create this file in the correct path,
99
+ # that is;
100
+ #
101
+ # app/controllers/forced/status_controller.rb
102
+
103
+ module Forced
104
+ class StatusController < ::ApplicationController
105
+ def index
106
+ response = Forced::Response.call(request)
107
+
108
+ # Do what you want to do with the response hash.
109
+ end
110
+ end
111
+ end
112
+ ```
113
+
114
+ To create a record, you can use your Rails console. `Forced::Client` is polymorphic and keeps `foreign_key` and `foreign_type` columns as `owner_#`. So, when you are creating a `Forced::Client` instance, use `owner:` for your reference column, e.g. `Forced::Client.create(owner: Brand.first)`
95
115
 
96
116
  ```ruby
97
117
  Forced::Client.new
98
- # => #<Forced::Client id: nil, item_type: nil, item_id: nil, identifier: nil, deleted_at: nil, created_at: nil, updated_at: nil>
118
+ # => #<Forced::Client id: nil, owner_type: nil, owner_id: nil, identifier: nil, deleted_at: nil, created_at: nil, updated_at: nil>
99
119
 
100
120
  Forced::Version.new
101
121
  # => #<Forced::Version id: nil, client_id: nil, version: nil, force_update: false, changelog: nil, deleted_at: nil, created_at: nil, updated_at: nil>
@@ -105,7 +125,7 @@ Forced::Version.new
105
125
 
106
126
  All available under `Forced::MESSAGES` hash table. You can override the values as you wish. Also checkout the `check_update_status` private method in `base.rb` to understand the cases.
107
127
 
108
- ## Upgrading from 0.2.0 to 1.0.0
128
+ ## Upgrading from 0.2.0 to 1.2.0
109
129
 
110
130
  New migrations and tables have a different name, so, unless you are using custom calls, you can optionally and gradually create a migration for old table and move your records into the new table.
111
131
 
@@ -3,8 +3,8 @@
3
3
  # Table name: forced_clients
4
4
  #
5
5
  # id :integer not null, primary key
6
- # item_type :string
7
- # item_id :integer
6
+ # owner_type :string
7
+ # owner_id :integer
8
8
  # identifier :string
9
9
  # deleted_at :datetime
10
10
  # created_at :datetime not null
@@ -13,7 +13,7 @@
13
13
 
14
14
  module Forced
15
15
  class Client < ApplicationRecord
16
- belongs_to :item, polymorphic: true, optional: true
16
+ belongs_to :owner, polymorphic: true, optional: true
17
17
 
18
18
  has_many :versions, class_name: 'Forced::Version', foreign_key: 'client_id', dependent: :destroy
19
19
  end
@@ -1,7 +1,7 @@
1
1
  module Forced
2
2
  MAJOR = 1
3
- MINOR = 1
4
- TINY = 1
3
+ MINOR = 2
4
+ TINY = 0
5
5
  PRE = nil
6
6
 
7
7
  VERSION = [MAJOR, MINOR, TINY, PRE].compact.join('.').freeze
@@ -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, dependent: :destroy
6
+ has_many :clients, class_name: 'Forced::Client', as: :owner, dependent: :destroy
7
7
  end
8
8
  end
9
9
  end
@@ -4,7 +4,7 @@
4
4
  class CreateForcedTables < ActiveRecord::Migration<%= migration_version %>
5
5
  def change
6
6
  create_table :forced_clients<%= forced_table_options %> do |t|
7
- t.references :item, polymorphic: true, index: true
7
+ t.references :owner, polymorphic: true, index: true
8
8
  t.string :identifier, index: { unique: true }
9
9
  t.datetime :deleted_at
10
10
 
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.1.1
4
+ version: 1.2.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-07 00:00:00.000000000 Z
11
+ date: 2018-11-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails