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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4f309011778dc4185040a0e57030c8ec4b2c68b8
4
- data.tar.gz: 3fbd0438bce1b8dde1878d0cd06f556890a31c82
3
+ metadata.gz: 76bd0febe777a23bef325f353c73bd659fcea5b3
4
+ data.tar.gz: 62cfda9058cda562125b79c23453e5702f17b557
5
5
  SHA512:
6
- metadata.gz: 065d95b351abf0809a930f16a546dc31c0233fdebb4c568af16ab2c7d77d403072035b284bb84579ab569a324ddfae038a5b3268f8e0bd231b8844eb021c4346
7
- data.tar.gz: 3577f1d3b061765bfb6af49702d351f50ee720d1ff8257fcb3ca4c0e046e9614cec421ba578bb6a6f09ea688471d6d4749855c7a31571e48919ad72d9655af54
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
- For now just a wrapper around the gem 'reform' (see https://github.com/apotonick/reform).
3
+ Rails compatible view models ignoring persistence.
4
+ Just a wrapper around the gems 'virtus' and 'activemodel'.
5
5
 
6
- `ViewModel::Base` simply inherits from `Reform::Form`
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
- BusinessModel = Class.new
24
- ViewModel::Base.new(BusinessModel.new)
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
  ```
@@ -1,6 +1,14 @@
1
- require 'reform'
1
+ require 'virtus'
2
+ require 'active_model'
2
3
 
3
4
  module ViewModel
4
- class Base < Reform::Form
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
@@ -1,3 +1,3 @@
1
1
  module ViewModel
2
- VERSION = '0.0.1'
2
+ VERSION = '0.0.2'
3
3
  end
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 'reform'
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.1
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-18 00:00:00.000000000 Z
11
+ date: 2015-03-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: reform
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: '0'
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: '0'
40
+ version: '3.2'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: bundler
29
43
  requirement: !ruby/object:Gem::Requirement