activeentity 0.0.1.beta1 → 0.0.1.beta2

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: 2e112f03678388841535d5384522961d51cc1d329ca4d1a89fdf7ce2ac7f60de
4
- data.tar.gz: 4b28acea8267bdffe02ff95a4d17522e69bd81475301e7a4f721f9097ab79fb7
3
+ metadata.gz: 0215e4356c9e29cf1cf6fb72344f86ca57c40cf25c343843cdc9f1704e484b5a
4
+ data.tar.gz: ac7db0df9a926d04bc9f8549ff2a0e783dbc360cce37ad39efa6bc191d4c370d
5
5
  SHA512:
6
- metadata.gz: b0c1ba8f2a0b214a556442a32f01777622a556e3e3e07884c5e8cf7ddef8d1bf60daab6807942f04e62c936c19a271ce9db79bc91437f55b94f608992647923b
7
- data.tar.gz: 9066e333b4dc888dd705726a44ce644438f9619ea0631507716c7a1e3553a32d99cc0deb44f8ea3ee716412cbb48688f69150aeeddc46327e57c9c9c8e1d7cbb
6
+ metadata.gz: 1f727df3be41108bb4c244dbaf0c5fd24706f5c6f8da3885fdbbe7fd31075b0ab8c1e096393216f9b62840e7f40ab6156f0d88e474474a75ce90a6fe8ee338fb
7
+ data.tar.gz: 4a88472fe279a168ba4f217a5b1bde40126501424ce4494af9bbb3feeaef9897c067b136f124b7dd9eb52a37d5091864cb37ec56be64f7b5b528ece479f4459c
data/README.md CHANGED
@@ -29,12 +29,13 @@ One enhancement is `array: true` that transform the attribute to an array that c
29
29
  Active Entity supports its own variant of nested attributes via the `embeds_one` / `embeds_many` macros. The intention is to be mostly compatible with ActiveRecord's `accepts_nested_attributes` functionality.
30
30
 
31
31
  ```ruby
32
- class Holiday < ActiveRecord::Base
32
+ class Holiday < ActiveEntity::Base
33
+ attribute :date, :date
33
34
  validates :date, presence: true
34
35
  end
35
36
 
36
- class HolidaysForm < ActiveType::Object
37
- nests_many :holidays, reject_if: :all_blank
37
+ class HolidaysForm < ActiveEntity::Base
38
+ embeds_many :holidays, reject_if: :all_blank
38
39
  end
39
40
  ```
40
41
 
@@ -70,7 +71,7 @@ Active Entity provides `subset` validation to achieve that, it usage similar to
70
71
  ```ruby
71
72
  class Steak < ActiveEntity::Base
72
73
  attribute :side_dishes, :string, array: true, default: []
73
- validates :side_dishes, subset: { in: %w(chips mashed_potato salad)
74
+ validates :side_dishes, subset: { in: %w(chips mashed_potato salad) }
74
75
  end
75
76
  ```
76
77
 
@@ -78,26 +79,33 @@ end
78
79
 
79
80
  Active Entity provides `uniqueness_in_embedding` validation to test duplicate nesting virtual record.
80
81
 
82
+ Argument `key` is attribute name of nested model, it also supports multiple attributes by given an array.
83
+
81
84
  ```ruby
82
85
  class Category < ActiveEntity::Base
83
- attribute :name
86
+ attribute :name, :string
87
+ end
88
+
89
+ class Reviewer < ActiveEntity::Base
90
+ attribute :first_name, :string
91
+ attribute :last_name, :string
84
92
  end
85
93
 
86
94
  class Book < ActiveEntity::Base
87
95
  embeds_many :categories
88
-
89
96
  validates :categories, uniqueness_in_embedding: {key: :name}
97
+
98
+ embeds_many :reviewers
99
+ validates :categories, uniqueness_in_embedding: {key: [:first_name, :last_name]}
90
100
  end
91
101
  ```
92
102
 
93
- Argument `key` is attribute name of nested model, it also supports multiple attributes by given an array.
94
-
95
103
  ### Others
96
104
 
97
105
  These Active Record feature also available in Active Entity
98
106
 
99
107
  - [`composed_of`](https://api.rubyonrails.org/classes/ActiveRecord/Aggregations/ClassMethods.html)
100
- - [`enum`](https://api.rubyonrails.org/v5.2.2/classes/ActiveRecord/Enum.html) (You must declare the attribute which use for `enum` first)
108
+ - [`enum`](https://api.rubyonrails.org/v5.2.2/classes/ActiveRecord/Enum.html) (You must declare the attribute before using `enum`)
101
109
  - [`serializable_hash`](https://api.rubyonrails.org/classes/ActiveModel/Serialization.html#method-i-serializable_hash)
102
110
  - [`serialize`](https://api.rubyonrails.org/classes/ActiveRecord/AttributeMethods/Serialization/ClassMethods.html#method-i-serialize)
103
111
  - [`store`](https://api.rubyonrails.org/classes/ActiveRecord/Store.html)
@@ -114,6 +122,16 @@ You can use `enable_readonly!` and `disable_readonly!` to control the behavior.
114
122
 
115
123
  **Important: It's no effect with embeds or array attributes !!!**
116
124
 
125
+ ## Extending
126
+
127
+ Most of Active Model plugins are compatible with Active Entity.
128
+
129
+ You need to include them manually.
130
+
131
+ Tested extensions:
132
+
133
+ - [adzap/validates_timeliness](https://github.com/adzap/validates_timeliness)
134
+
117
135
  ## Installation
118
136
 
119
137
  Add this line to your application's Gemfile:
@@ -132,6 +150,10 @@ Or install it yourself as:
132
150
  $ gem install activeentity
133
151
  ```
134
152
 
153
+ ## Other awesome gems
154
+
155
+ - [makandra/active_type](https://github.com/makandra/active_type)
156
+
135
157
  ## Contributing
136
158
 
137
159
  - Fork the project.
@@ -236,6 +236,14 @@ module ActiveEntity
236
236
  Hash[methods.flatten.map! { |method| [method, public_send(method)] }].with_indifferent_access
237
237
  end
238
238
 
239
+ def present? # :nodoc:
240
+ true
241
+ end
242
+
243
+ def blank? # :nodoc:
244
+ false
245
+ end
246
+
239
247
  private
240
248
 
241
249
  # +Array#flatten+ will call +#to_ary+ (recursively) on each of the elements of
@@ -10,7 +10,7 @@ module ActiveEntity
10
10
  MAJOR = 0
11
11
  MINOR = 0
12
12
  TINY = 1
13
- PRE = "beta1"
13
+ PRE = "beta2"
14
14
 
15
15
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
16
16
  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.beta1
4
+ version: 0.0.1.beta2
5
5
  platform: ruby
6
6
  authors:
7
7
  - jasl
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-01-19 00:00:00.000000000 Z
11
+ date: 2019-04-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -16,7 +16,7 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 6.0.0.beta1
19
+ version: 6.0.0.beta3
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
22
  version: '7.0'
@@ -26,7 +26,7 @@ dependencies:
26
26
  requirements:
27
27
  - - ">="
28
28
  - !ruby/object:Gem::Version
29
- version: 6.0.0.beta1
29
+ version: 6.0.0.beta3
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
32
  version: '7.0'
@@ -36,7 +36,7 @@ dependencies:
36
36
  requirements:
37
37
  - - ">="
38
38
  - !ruby/object:Gem::Version
39
- version: 6.0.0.beta1
39
+ version: 6.0.0.beta3
40
40
  - - "<"
41
41
  - !ruby/object:Gem::Version
42
42
  version: '7.0'
@@ -46,7 +46,7 @@ dependencies:
46
46
  requirements:
47
47
  - - ">="
48
48
  - !ruby/object:Gem::Version
49
- version: 6.0.0.beta1
49
+ version: 6.0.0.beta3
50
50
  - - "<"
51
51
  - !ruby/object:Gem::Version
52
52
  version: '7.0'
@@ -148,7 +148,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
148
148
  - !ruby/object:Gem::Version
149
149
  version: 1.3.1
150
150
  requirements: []
151
- rubygems_version: 3.0.2
151
+ rubygems_version: 3.0.3
152
152
  signing_key:
153
153
  specification_version: 4
154
154
  summary: Rails virtual model solution based on ActiveModel.