active_value 1.0.1 → 1.0.2
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 +4 -4
- data/.github/workflows/test.yml +3 -1
- data/Appraisals +19 -0
- data/README.md +30 -6
- data/active_value.gemspec +6 -2
- data/gemfiles/ruby_2.3.gemfile +7 -0
- data/gemfiles/ruby_2.5.gemfile +7 -0
- data/gemfiles/ruby_2.7.gemfile +7 -0
- data/gemfiles/ruby_3.gemfile +7 -0
- data/lib/active_value/version.rb +1 -1
- metadata +28 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1427365469e27374bc138221f4b407a579e048997821d4da98aba02f2886bf24
|
4
|
+
data.tar.gz: efdc46072d4740678a140ac133cc340f60d2c901e4cfdca706978cdf2170a6f6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3844219f8857f6a3c8cb6d87d97e5490d914e9916128d5ee52a1789ed108a5c05e2d590f1a3566f557ae4f4ed9ec59a45f961992a7af48a229d4ad36124722ee
|
7
|
+
data.tar.gz: 87b08dd151e1563b63c5d17207832829cd2a207477b533b4812e5ef1ebcf925c4ec754ad452aa5ab2f96f048a148b55bd5827733d96bfd3e06dac39dc25eb96f
|
data/.github/workflows/test.yml
CHANGED
data/Appraisals
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# Appraisal DSL File
|
2
|
+
# To test the library against different versions of dependencies
|
3
|
+
# `bundle exec appraisal install` command generates `gemfiles/ruby_3.0.gemfile` file etc.
|
4
|
+
|
5
|
+
appraise "ruby-3" do
|
6
|
+
gem "activesupport", "~> 6.1.0"
|
7
|
+
end
|
8
|
+
|
9
|
+
appraise "ruby-2.7" do
|
10
|
+
gem "activesupport", "~> 6.0.3"
|
11
|
+
end
|
12
|
+
|
13
|
+
appraise "ruby-2.5" do
|
14
|
+
gem "activesupport", "~> 5.2.4"
|
15
|
+
end
|
16
|
+
|
17
|
+
appraise "ruby-2.3" do
|
18
|
+
gem "activesupport", "~> 5.2.4"
|
19
|
+
end
|
data/README.md
CHANGED
@@ -1,12 +1,19 @@
|
|
1
|
+
# ActiveValue
|
2
|
+
|
1
3
|

|
2
4
|

|
3
5
|

|
4
6
|

|
5
7
|
|
6
|
-
|
8
|
+
#### Overviews
|
7
9
|
|
8
10
|
ActiveValue::Base is base class for immutable value object that has interfaces like ActiveRecord.
|
9
|
-
In a class inherited this class, constant variables get the behavior like records of ActiveRecord.
|
11
|
+
In a class inherited this class, constant variables get the behavior like records of ActiveRecord.
|
12
|
+
|
13
|
+
#### Supported Verisons
|
14
|
+
|
15
|
+
Support Ruby 2.3 or later
|
16
|
+
Unit tests are passed with Ruby [2.3, 2.5, 2,7, 3.0] on GitHub Actions
|
10
17
|
|
11
18
|
## Installation
|
12
19
|
|
@@ -48,20 +55,37 @@ Then, constant variables in the class can be accessed by following methods.
|
|
48
55
|
```ruby
|
49
56
|
FormCategory.find(1)
|
50
57
|
=> <#FormCategory id: 1, symbol: :checkbox, name: "Check Box" >
|
58
|
+
# Also can be accessed by FormCategory::CHECK_BOX
|
51
59
|
|
52
|
-
FormCategory.find_by(symbol: :
|
53
|
-
=> "
|
60
|
+
FormCategory.find_by(symbol: :checkbox).name
|
61
|
+
=> "Check Box"
|
54
62
|
|
55
63
|
FormCategory.find(1).checkbox?
|
56
64
|
=> true
|
57
65
|
|
66
|
+
FormCategory.find(2).to_h
|
67
|
+
=> { :id => 2, :symbol => :radio, :name => "Radio Button" }
|
68
|
+
```
|
69
|
+
Getter methods for multiple objects are also provided.
|
70
|
+
```ruby
|
71
|
+
FormCategory.all
|
72
|
+
=> [<#FormCategory id: 1, symbol: :checkbox, name: "Check Box" >, <#FormCategory id: 2, symbol: :radio, name: "Radio Button" >, ...]
|
73
|
+
|
58
74
|
FormCategory.pluck(:id, :name)
|
59
75
|
=> [[1, "Check Box"], [2, "Radio Button"], [3, "Select Box"], ...]
|
60
76
|
|
61
|
-
|
62
|
-
|
77
|
+
# Undefined method calls delegate to the all method.
|
78
|
+
FormCateory.select { |category| category.name.start_with("Text") }
|
79
|
+
=> [<#FormCategory id: 4, symbol: :text, name: "Text Box" >, <#FormCategory id: 5, symbol: :textarea, name: "Text Area" >]
|
63
80
|
```
|
64
81
|
|
82
|
+
## Specified Attributes
|
83
|
+
|
84
|
+
`id` and `symbol` are specified attributes. (not required)
|
85
|
+
- If `id` attribute is defined, you can access a instance using `find` class method.
|
86
|
+
- If `symbol` attribute is defined, you can test a instance has the symbol like `FormCategory.find(1).checkbox?`.
|
87
|
+
|
88
|
+
|
65
89
|
|
66
90
|
## Contributing
|
67
91
|
|
data/active_value.gemspec
CHANGED
@@ -25,7 +25,11 @@ Gem::Specification.new do |spec|
|
|
25
25
|
|
26
26
|
spec.add_development_dependency "bundler", "> 1.0.0"
|
27
27
|
spec.add_development_dependency "rake", "> 10.0"
|
28
|
-
spec.add_development_dependency "minitest", "
|
28
|
+
spec.add_development_dependency "minitest", "~> 5.14"
|
29
|
+
spec.add_development_dependency "appraisal"
|
30
|
+
# For Version 1.1
|
31
|
+
# spec.add_development_dependency "activerecord", ">= 4.0.0"
|
32
|
+
# spec.add_development_dependency "sqlite3"
|
29
33
|
|
30
|
-
spec.add_dependency "activesupport", "
|
34
|
+
spec.add_dependency "activesupport", ">= 4.0.0"
|
31
35
|
end
|
data/lib/active_value/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_value
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Taiki Hiramatsu
|
@@ -42,30 +42,44 @@ dependencies:
|
|
42
42
|
name: minitest
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '5.
|
47
|
+
version: '5.14'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '5.
|
54
|
+
version: '5.14'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: appraisal
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: activesupport
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
58
72
|
requirements:
|
59
|
-
- - "
|
73
|
+
- - ">="
|
60
74
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
75
|
+
version: 4.0.0
|
62
76
|
type: :runtime
|
63
77
|
prerelease: false
|
64
78
|
version_requirements: !ruby/object:Gem::Requirement
|
65
79
|
requirements:
|
66
|
-
- - "
|
80
|
+
- - ">="
|
67
81
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
82
|
+
version: 4.0.0
|
69
83
|
description: In a class inherited this class, constant variables get the behavior
|
70
84
|
like records of ActiveRecord.
|
71
85
|
email:
|
@@ -78,6 +92,7 @@ files:
|
|
78
92
|
- ".github/workflows/test.yml"
|
79
93
|
- ".gitignore"
|
80
94
|
- ".travis.yml"
|
95
|
+
- Appraisals
|
81
96
|
- Gemfile
|
82
97
|
- LICENSE.txt
|
83
98
|
- README.md
|
@@ -85,6 +100,10 @@ files:
|
|
85
100
|
- active_value.gemspec
|
86
101
|
- bin/console
|
87
102
|
- bin/setup
|
103
|
+
- gemfiles/ruby_2.3.gemfile
|
104
|
+
- gemfiles/ruby_2.5.gemfile
|
105
|
+
- gemfiles/ruby_2.7.gemfile
|
106
|
+
- gemfiles/ruby_3.gemfile
|
88
107
|
- lib/active_value.rb
|
89
108
|
- lib/active_value/base.rb
|
90
109
|
- lib/active_value/version.rb
|