activeentity 0.0.1.beta2 → 0.0.1.beta3

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: 0215e4356c9e29cf1cf6fb72344f86ca57c40cf25c343843cdc9f1704e484b5a
4
- data.tar.gz: ac7db0df9a926d04bc9f8549ff2a0e783dbc360cce37ad39efa6bc191d4c370d
3
+ metadata.gz: 8939ee2c816d857682536b7bf8de1901f42334db49b55fb4c29c9845e809888a
4
+ data.tar.gz: 4dc520b5bf0c6864a41ca5a12e67c5ff043ab5994444375c83c2dba3d98c0c5e
5
5
  SHA512:
6
- metadata.gz: 1f727df3be41108bb4c244dbaf0c5fd24706f5c6f8da3885fdbbe7fd31075b0ab8c1e096393216f9b62840e7f40ab6156f0d88e474474a75ce90a6fe8ee338fb
7
- data.tar.gz: 4a88472fe279a168ba4f217a5b1bde40126501424ce4494af9bbb3feeaef9897c067b136f124b7dd9eb52a37d5091864cb37ec56be64f7b5b528ece479f4459c
6
+ metadata.gz: 2a6bb6eca6b8dde1d8fba089c9ab679eea8b72a46479f9cd9ce211294808b9a339a0a472bcdaff6d31799634d197265ee3e63a23d0edb55d2d1921c9b8d568ac
7
+ data.tar.gz: 3ed46914914b39ec49829d689d16c09ddffd95b7060ec4bd789938467f9694f22115f6b39c09e988088065196dd01643ed095fab75ecd1a3ce7242ff0f546afc
@@ -4,6 +4,8 @@ require "active_support"
4
4
  require "active_support/rails"
5
5
  require "yaml"
6
6
 
7
+ require "core_ext/array_without_blank"
8
+
7
9
  require "active_model"
8
10
  require "active_model/attribute_set"
9
11
 
@@ -10,7 +10,7 @@ module ActiveEntity
10
10
  MAJOR = 0
11
11
  MINOR = 0
12
12
  TINY = 1
13
- PRE = "beta2"
13
+ PRE = "beta3"
14
14
 
15
15
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
16
16
  end
@@ -13,6 +13,7 @@ require "active_entity/type/text"
13
13
  require "active_entity/type/unsigned_integer"
14
14
 
15
15
  require "active_entity/type/modifiers/array"
16
+ require "active_entity/type/modifiers/array_without_blank"
16
17
 
17
18
  require "active_entity/type/serialized"
18
19
  require "active_entity/type/registry"
@@ -56,6 +57,7 @@ module ActiveEntity
56
57
  Value = ActiveModel::Type::Value
57
58
 
58
59
  add_modifier({ array: true }, Modifiers::Array)
60
+ add_modifier({ array_without_blank: true }, Modifiers::ArrayWithoutBlank)
59
61
 
60
62
  register(:big_integer, Type::BigInteger, override: false)
61
63
  register(:binary, Type::Binary, override: false)
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActiveEntity
4
+ module Type
5
+ module Modifiers
6
+ class ArrayWithoutBlank < Array # :nodoc:
7
+ private
8
+
9
+ def type_cast_array(value, method)
10
+ if value.is_a?(::Array)
11
+ ::ArrayWithoutBlank.new value.map { |item| type_cast_array(item, method) }
12
+ else
13
+ @subtype.public_send(method, value)
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ class ArrayWithoutBlank < Array
4
+ def self.new(*several_variants)
5
+ arr = super
6
+ arr.reject!(&:blank?)
7
+ arr
8
+ end
9
+
10
+ def initialize_copy(other_ary)
11
+ super other_ary.reject(&:blank?)
12
+ end
13
+
14
+ def replace(other_ary)
15
+ super other_ary.reject(&:blank?)
16
+ end
17
+
18
+ def push(obj, *smth)
19
+ return self if obj.blank?
20
+ super
21
+ end
22
+
23
+ def insert(*args)
24
+ super(*args.reject(&:blank?))
25
+ end
26
+
27
+ def []=(index, obj)
28
+ return self[index] if obj.blank?
29
+ super
30
+ end
31
+
32
+ def concat(other_ary)
33
+ super other_ary.reject(&:blank?)
34
+ end
35
+
36
+ def +(other_ary)
37
+ super other_ary.reject(&:blank?)
38
+ end
39
+
40
+ def <<(obj)
41
+ return self if obj.blank?
42
+ super
43
+ end
44
+
45
+ def to_ary
46
+ Array.new(self)
47
+ end
48
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activeentity
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1.beta2
4
+ version: 0.0.1.beta3
5
5
  platform: ruby
6
6
  authors:
7
7
  - jasl
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-04-12 00:00:00.000000000 Z
11
+ date: 2019-04-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -113,6 +113,7 @@ files:
113
113
  - lib/active_entity/type/internal/timezone.rb
114
114
  - lib/active_entity/type/json.rb
115
115
  - lib/active_entity/type/modifiers/array.rb
116
+ - lib/active_entity/type/modifiers/array_without_blank.rb
116
117
  - lib/active_entity/type/registry.rb
117
118
  - lib/active_entity/type/serialized.rb
118
119
  - lib/active_entity/type/text.rb
@@ -128,6 +129,7 @@ files:
128
129
  - lib/active_entity/validations/subset.rb
129
130
  - lib/active_entity/validations/uniqueness_in_embedding.rb
130
131
  - lib/active_entity/version.rb
132
+ - lib/core_ext/array_without_blank.rb
131
133
  - lib/tasks/active_entity_tasks.rake
132
134
  homepage: https://github.com/jasl/activeentity
133
135
  licenses: