comee_core 0.1.55 → 0.1.56

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
  SHA256:
3
- metadata.gz: 3751acb01c5cf8b05e174b4d0009ea3b2aaed413f0b6141385adf270b9f892e3
4
- data.tar.gz: fceb35fd157fa37762bdbf691e84d916b97111c569a18083d87e05973e234c49
3
+ metadata.gz: ead330a4756361db4ef55e9a2716c50fc103c78c17cc18a197e42b1363ce4d4a
4
+ data.tar.gz: 4f88d44825eccafe77978ae5e71906af4afe657955fc20ead6cde17e035eab8c
5
5
  SHA512:
6
- metadata.gz: 20f100406e4bffb1d983d4cba3c1e38a23a2eb110160e50389f3e4fdacf2c991b95d4be49631e32767776e80c179bd0b1ca4b5dbdcfa95a41f2784dd2ea61754
7
- data.tar.gz: ae8c388051f649c1f2e172df40da4923aeca3732f32bd7f066c83f1a04b37b53d42fef51a07f6c6aac156258b137e4298da3d31656cf4242cd43b16a0809267c
6
+ metadata.gz: 9a217c3a5f68e644bde348dff1821170f087f24a4b652f28e840de2ed1c52dd4daf581d837e2e359b014f75842652078146087ad10fcd41beead9896e42f34ca
7
+ data.tar.gz: 713f0e53ba812000b184a81c55c04e8b83b3977397906718c8adc8970de5463c0706a4884942ec95357353f6edac3bc7a431f4bea81a099851aca1ff39730ad2
@@ -6,7 +6,7 @@ module Comee
6
6
  private
7
7
 
8
8
  def model_params
9
- params.require(:payload).permit(:code, :name, :unit_type)
9
+ params.require(:payload).permit(:code, :name, :unit_type, aliases: [])
10
10
  end
11
11
  end
12
12
  end
@@ -1,10 +1,18 @@
1
1
  module Comee
2
2
  module Core
3
3
  class Unit < ApplicationRecord
4
+ before_save :downcase_aliases
5
+
4
6
  enum :unit_type, {weight: 0, volume: 1, item: 2}
5
7
 
6
8
  validates :code, presence: true, uniqueness: true
7
9
  validates :name, presence: true
10
+
11
+ def downcase_aliases
12
+ return if aliases.count.zero? || aliases.nil?
13
+
14
+ aliases.map(&:downcase!)
15
+ end
8
16
  end
9
17
  end
10
18
  end
@@ -1,7 +1,7 @@
1
1
  module Comee
2
2
  module Core
3
3
  class UnitSerializer < ActiveModel::Serializer
4
- attributes :id, :code, :name, :unit_type
4
+ attributes :id, :code, :name, :unit_type, :aliases
5
5
  end
6
6
  end
7
7
  end
@@ -4,6 +4,7 @@ class CreateComeeCoreUnits < ActiveRecord::Migration[7.0]
4
4
  t.string :code, null: false
5
5
  t.string :name, null: false
6
6
  t.integer :unit_type, null: false, default: 0
7
+ t.string :aliases, array: true, default: []
7
8
 
8
9
  t.timestamps
9
10
  end
@@ -1,5 +1,5 @@
1
1
  module Comee
2
2
  module Core
3
- VERSION = "0.1.55".freeze
3
+ VERSION = "0.1.56".freeze
4
4
  end
5
5
  end
@@ -3,5 +3,6 @@ FactoryBot.define do
3
3
  sequence(:code) { |n| "#{Faker::Alphanumeric.alpha(number: 2)}-#{n}" }
4
4
  name { Faker::Name.name }
5
5
  unit_type { Comee::Core::Unit.unit_types[:weight] }
6
+ aliases { [] }
6
7
  end
7
8
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: comee_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.55
4
+ version: 0.1.56
5
5
  platform: ruby
6
6
  authors:
7
7
  - Henock L.