gourami 0.1.1 → 0.1.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/LICENSE.txt +1 -1
- data/README.md +21 -21
- data/gourami.gemspec +2 -2
- data/lib/gourami/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5a514a33e36dee0b4a2c39ef0320f4a8fa70ab24
|
4
|
+
data.tar.gz: 6acabd9872fd0346833fa7f50b527d1413a202f0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 97e2db4cccf243740e2e1548673df9860a06aeb856516c77e9596bab2ff06c39c86c982266a5cbe24d33b6383d885cc1e4411d0fb934c7570628de2000edbfa7
|
7
|
+
data.tar.gz: 15cff403f9f9a2d2a7536278fa114fff0f503e8a13e539546f8ae049d978c76231c71fe7e60c5c65721b4761d2178bd6dd4340be5fbd23f3f472f635a6111f35
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -46,11 +46,11 @@ end
|
|
46
46
|
|
47
47
|
```ruby
|
48
48
|
def new
|
49
|
-
@form =
|
49
|
+
@form = CreateFishBowl.new
|
50
50
|
end
|
51
51
|
|
52
52
|
def create
|
53
|
-
@form =
|
53
|
+
@form = CreateFishBowl.new(fish_bowl_params)
|
54
54
|
|
55
55
|
if @form.valid?
|
56
56
|
@form.perform
|
@@ -64,9 +64,9 @@ end
|
|
64
64
|
### Example of a form that Creates a record
|
65
65
|
|
66
66
|
```ruby
|
67
|
-
class
|
67
|
+
class CreateFishBowl < Gourami::Form
|
68
68
|
|
69
|
-
record(:
|
69
|
+
record(:fish_bowl)
|
70
70
|
|
71
71
|
attribute(:width, type: :integer)
|
72
72
|
attribute(:height, type: :integer)
|
@@ -86,12 +86,12 @@ class CreateFishTank < Gourami::Form
|
|
86
86
|
|
87
87
|
validate_presence(:name)
|
88
88
|
validate_uniqueness(:name) do |name|
|
89
|
-
|
89
|
+
FishBowl.where(name: name).empty?
|
90
90
|
end
|
91
91
|
end
|
92
92
|
|
93
93
|
def perform
|
94
|
-
self.
|
94
|
+
self.fish_bowl = FishBowl.create(attributes)
|
95
95
|
end
|
96
96
|
|
97
97
|
end
|
@@ -101,12 +101,12 @@ end
|
|
101
101
|
|
102
102
|
```ruby
|
103
103
|
def edit
|
104
|
-
|
105
|
-
@form =
|
104
|
+
fish_bowl = FishBowl.find(params[:id])
|
105
|
+
@form = UpdateFishBowl.new_from_record(fish_bowl)
|
106
106
|
end
|
107
107
|
|
108
108
|
def update
|
109
|
-
@form =
|
109
|
+
@form = UpdateFishBowl.new(fish_bowl_params)
|
110
110
|
|
111
111
|
if @form.valid?
|
112
112
|
@form.perform
|
@@ -120,9 +120,9 @@ end
|
|
120
120
|
### Example of a form that Updates a record
|
121
121
|
|
122
122
|
```ruby
|
123
|
-
class
|
123
|
+
class UpdateFishBowl < CreateFishBowl
|
124
124
|
|
125
|
-
record(:
|
125
|
+
record(:fish_bowl)
|
126
126
|
|
127
127
|
attribute(:width, type: :integer)
|
128
128
|
attribute(:height, type: :integer)
|
@@ -130,8 +130,8 @@ class UpdateFishTank < CreateFishTank
|
|
130
130
|
attribute(:name, type: :string)
|
131
131
|
attribute(:filter_included, type: :boolean, default: false)
|
132
132
|
|
133
|
-
def self.new_from_record(
|
134
|
-
new({
|
133
|
+
def self.new_from_record(fish_bowl)
|
134
|
+
new({ fish_bowl: fish_bowl }.merge(fish_bowl.attributes))
|
135
135
|
end
|
136
136
|
|
137
137
|
def validate
|
@@ -146,12 +146,12 @@ class UpdateFishTank < CreateFishTank
|
|
146
146
|
|
147
147
|
validate_presence(:name)
|
148
148
|
validate_uniqueness(:name) do |name|
|
149
|
-
|
149
|
+
FishBowl.where(name: name).empty?
|
150
150
|
end
|
151
151
|
end
|
152
152
|
|
153
153
|
def perform
|
154
|
-
|
154
|
+
fish_bowl.update(attributes)
|
155
155
|
end
|
156
156
|
|
157
157
|
end
|
@@ -160,16 +160,16 @@ end
|
|
160
160
|
#### Or inherit instead of duplicating the attributes and validations
|
161
161
|
|
162
162
|
```ruby
|
163
|
-
class
|
163
|
+
class UpdateFishBowl < CreateFishBowl
|
164
164
|
|
165
|
-
# All attributes and validations inherited from
|
165
|
+
# All attributes and validations inherited from CreateFishBowl.
|
166
166
|
|
167
|
-
def self.new_from_record(
|
168
|
-
new({
|
167
|
+
def self.new_from_record(fish_bowl)
|
168
|
+
new({ fish_bowl: fish_bowl }.merge(fish_bowl.attributes))
|
169
169
|
end
|
170
170
|
|
171
171
|
def perform
|
172
|
-
|
172
|
+
fish_bowl.update(attributes)
|
173
173
|
end
|
174
174
|
|
175
175
|
end
|
@@ -183,7 +183,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
183
183
|
|
184
184
|
## Contributing
|
185
185
|
|
186
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
186
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/Vydia/gourami. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
187
187
|
|
188
188
|
## License
|
189
189
|
|
data/gourami.gemspec
CHANGED
@@ -7,11 +7,11 @@ Gem::Specification.new do |spec|
|
|
7
7
|
spec.name = "gourami"
|
8
8
|
spec.version = Gourami::VERSION
|
9
9
|
spec.authors = ["TSMMark"]
|
10
|
-
spec.email = ["
|
10
|
+
spec.email = ["dev@vydia.com"]
|
11
11
|
|
12
12
|
spec.summary = %q{Keep your Routes, Controllers and Models thin.}
|
13
13
|
spec.description = %q{Create Plain Old Ruby Objects that take attributes, validate them, and perform an action.}
|
14
|
-
spec.homepage = "http://github.com/
|
14
|
+
spec.homepage = "http://github.com/Vydia/gourami"
|
15
15
|
spec.license = "MIT"
|
16
16
|
|
17
17
|
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
data/lib/gourami/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gourami
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- TSMMark
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-05-
|
11
|
+
date: 2017-05-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pry
|
@@ -69,7 +69,7 @@ dependencies:
|
|
69
69
|
description: Create Plain Old Ruby Objects that take attributes, validate them, and
|
70
70
|
perform an action.
|
71
71
|
email:
|
72
|
-
-
|
72
|
+
- dev@vydia.com
|
73
73
|
executables: []
|
74
74
|
extensions: []
|
75
75
|
extra_rdoc_files: []
|
@@ -94,7 +94,7 @@ files:
|
|
94
94
|
- lib/gourami/validation_error.rb
|
95
95
|
- lib/gourami/validations.rb
|
96
96
|
- lib/gourami/version.rb
|
97
|
-
homepage: http://github.com/
|
97
|
+
homepage: http://github.com/Vydia/gourami
|
98
98
|
licenses:
|
99
99
|
- MIT
|
100
100
|
metadata: {}
|