discriminable 1.0.2 → 2.0.0

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
  SHA256:
3
- metadata.gz: c1a3423c662438bd1da7de31f12799764809c5eab65f01f47f9ef29086275c6e
4
- data.tar.gz: a58ed066341f58fb7e992aff46476c56cb81812a5b09eba4e504adb8777594fa
3
+ metadata.gz: f0d473ffb5de9687b61d3ee960207d15fdc8a3f4d29fbd1a7498740c7cef3e35
4
+ data.tar.gz: 5a184093d1cf560fd87284447b7047c4b82fc266a530d9c05e1b9755a8044573
5
5
  SHA512:
6
- metadata.gz: 2063b2d10e32b21a3be1d5933adaa96311ff9c98b4a3da8c91638373964ee6e8806452f04b500b9d6303d345e9dc599b2d334e5b5f15f9529677ed230543af50
7
- data.tar.gz: 264d3cd6800f8e98a98f6dc1c8e3a74edbca0c7759fea7a3acff1b7eeee493dabf4ca0931c0453f8eff43f6a2d5bb7d4f63cf118a7e49f2dfb86f91e308ddf9b
6
+ metadata.gz: 347d5b0e409d013e34d64ce6bce73bb8a72e93fb0a872bed81919a4a2aca7c4335ceb6de667fd6a6249a624bb2a8ff2393251107891df5667cfed62c819b386b
7
+ data.tar.gz: e716b423ca4bd46bd7b34cbcb2b310773344a6bf572d4b0c376f60e04cbafe0233d7ae0e68fa91ba27e3d9bb7156b0ba477dca205e850049c518ff264299bfe4
data/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [2.0.0](https://github.com/gregorw/discriminable/compare/v1.0.2...v2.0.0) (2022-03-31)
4
+
5
+
6
+ ### ⚠ BREAKING CHANGES
7
+
8
+ * simplified api
9
+
10
+ ### Features
11
+
12
+ * simplified api ([1b05019](https://github.com/gregorw/discriminable/commit/1b05019dc42aff7fe9ce5c752d7ce8ce09f5b4b7))
13
+
14
+
15
+ ### Bug Fixes
16
+
17
+ * tests ([445cb05](https://github.com/gregorw/discriminable/commit/445cb053786c7a862dbeadcaa1af901832465632))
18
+
3
19
  ### [1.0.2](https://github.com/gregorw/discriminable/compare/v1.0.1...v1.0.2) (2022-03-31)
4
20
 
5
21
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Discriminable
4
- VERSION = "1.0.2"
4
+ VERSION = "2.0.0"
5
5
  end
data/lib/discriminable.rb CHANGED
@@ -17,25 +17,25 @@ require "active_support"
17
17
  # class Customer < ActiveRecord::Base
18
18
  # include Discriminable
19
19
  #
20
- # discriminable_by state: { lead: "Lead" }
20
+ # discriminable state: { lead: "Lead" }
21
21
  # end
22
22
  #
23
23
  module Discriminable
24
24
  extend ActiveSupport::Concern
25
25
 
26
26
  included do
27
- class_attribute :discriminable, instance_writer: false
27
+ class_attribute :discriminable_map, instance_writer: false
28
28
  class_attribute :discriminable_inverse, instance_writer: false
29
29
  end
30
30
 
31
31
  # Specify the column to use for discrimination.
32
32
  module ClassMethods
33
- def discriminable_by(**options)
34
- raise "Subclasses should not override .discriminable_by" unless base_class?
33
+ def discriminable(**options)
34
+ raise "Subclasses should not override .discriminable" unless base_class?
35
35
 
36
36
  discriminator, map = options.first
37
37
 
38
- self.discriminable = map.with_indifferent_access
38
+ self.discriminable_map = map.with_indifferent_access
39
39
  self.discriminable_inverse = map.invert
40
40
  self.inheritance_column = discriminator.to_s
41
41
  end
@@ -45,7 +45,7 @@ module Discriminable
45
45
  end
46
46
 
47
47
  def sti_class_for(value)
48
- return self unless (type_name = discriminable[value])
48
+ return self unless (type_name = discriminable_map[value])
49
49
 
50
50
  super type_name
51
51
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: discriminable
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gregor Wassmann