view_model 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +13 -5
- data/lib/view_model/base.rb +10 -2
- data/lib/view_model/version.rb +1 -1
- data/view_models.gemspec +2 -1
- metadata +19 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 76bd0febe777a23bef325f353c73bd659fcea5b3
|
4
|
+
data.tar.gz: 62cfda9058cda562125b79c23453e5702f17b557
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 517cb95a884bc471f8169cfab4e3727dac1b7100fa0c641353bf0b604ed908a1ac818510c28153dc1181ab2f89316698c5ccc4b9706c40685a7ad8af25af3f00
|
7
|
+
data.tar.gz: b008511fd0e35cf2afb7d3ab6d671ca2b4407c0d5fccb43e81923952315a1dfc71702f79a09b5dcf57a4a6041a9bbbb2f17dd8f732f2ec97362e521afb8d726b
|
data/README.md
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
# ViewModels
|
2
2
|
|
3
|
-
Rails compatible view models.
|
4
|
-
|
3
|
+
Rails compatible view models ignoring persistence.
|
4
|
+
Just a wrapper around the gems 'virtus' and 'activemodel'.
|
5
5
|
|
6
|
-
|
6
|
+
https://github.com/solnic/virtus
|
7
|
+
https://github.com/rails/rails/tree/master/activemodel
|
7
8
|
|
8
9
|
## Installation
|
9
10
|
|
@@ -20,6 +21,13 @@ And then execute:
|
|
20
21
|
## Usage
|
21
22
|
|
22
23
|
```ruby
|
23
|
-
|
24
|
-
|
24
|
+
class Profile < ViewModel::Base
|
25
|
+
attribute :name, String
|
26
|
+
validates :name, :presence => true
|
27
|
+
end
|
28
|
+
|
29
|
+
vm = Profile.new({:name => 'Bob'})
|
30
|
+
|
31
|
+
vm.valid? # => true
|
32
|
+
vm.attributes # => {:name => 'Bob'}
|
25
33
|
```
|
data/lib/view_model/base.rb
CHANGED
@@ -1,6 +1,14 @@
|
|
1
|
-
require '
|
1
|
+
require 'virtus'
|
2
|
+
require 'active_model'
|
2
3
|
|
3
4
|
module ViewModel
|
4
|
-
class Base
|
5
|
+
class Base
|
6
|
+
include Virtus.model
|
7
|
+
include ActiveModel::Validations
|
8
|
+
extend ActiveModel::Naming
|
9
|
+
|
10
|
+
def persisted?
|
11
|
+
false
|
12
|
+
end
|
5
13
|
end
|
6
14
|
end
|
data/lib/view_model/version.rb
CHANGED
data/view_models.gemspec
CHANGED
@@ -22,7 +22,8 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
23
23
|
spec.require_paths = ['lib']
|
24
24
|
|
25
|
-
spec.add_dependency '
|
25
|
+
spec.add_dependency 'virtus', '~> 1.0'
|
26
|
+
spec.add_dependency 'activemodel', '>= 3.2'
|
26
27
|
|
27
28
|
spec.add_development_dependency 'bundler', '~> 1.8'
|
28
29
|
spec.add_development_dependency 'rake', '~> 10.0'
|
metadata
CHANGED
@@ -1,29 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: view_model
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andreas Busold
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-03-
|
11
|
+
date: 2015-03-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: virtus
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: activemodel
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
16
30
|
requirements:
|
17
31
|
- - ">="
|
18
32
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
33
|
+
version: '3.2'
|
20
34
|
type: :runtime
|
21
35
|
prerelease: false
|
22
36
|
version_requirements: !ruby/object:Gem::Requirement
|
23
37
|
requirements:
|
24
38
|
- - ">="
|
25
39
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
40
|
+
version: '3.2'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: bundler
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|