zertico 0.3.0 → 0.3.1

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.
data/.travis.yml CHANGED
@@ -1,9 +1,7 @@
1
1
  rvm:
2
- - 1.8.7
3
2
  - 1.9.2
4
3
  - 1.9.3
5
4
  - jruby
6
- - ree
7
5
  gemfile:
8
6
  - gemfiles/Gemfile.rails3.1
9
- - gemfiles/Gemfile.rails3.2
7
+ - gemfiles/Gemfile.rails3.2
data/README.md CHANGED
@@ -57,6 +57,13 @@ Your service must be a module and include Zertico::Service to grant access to al
57
57
  Then you will have to redefine all the methods you need. Each action of the controller is mapped to a method.
58
58
  The method has to return a hash. The key must be the name of the global variable you want to use on the views.
59
59
 
60
+ Sometimes, the ActiveRecord models grow to much. It start to handle all kinds of logic. To make things simple,
61
+ it should only concern about database access. To clean it, use the Zertico::Accessor. It is a wrapper that will
62
+ pass all methods to the object unless the ones you overwrite. This way, is easy to start develop better models.
63
+
64
+ By using Zertico::Controller and Zertico::Accessor, a great part of you project will be simple ruby classes.
65
+ It means, better and simple tests, without depend on rails and any other external logic. =D
66
+
60
67
  ## Conventions
61
68
 
62
69
  To work with the gem, you will need to follow some conventions. Your model ( called interface here ) need to
@@ -71,6 +78,9 @@ module UserService
71
78
  include Zertico::Service
72
79
  end
73
80
 
81
+ class UserAccessor < Zertico::Accessor
82
+ end
83
+
74
84
  class User < ActiveRecord::Base
75
85
  end
76
86
  ```
@@ -91,4 +101,4 @@ It is good to put the services on a separate folder called services.
91
101
  2. Create your feature branch (`git checkout -b my-new-feature`)
92
102
  3. Commit your changes (`git commit -am 'Add some feature'`)
93
103
  4. Push to the branch (`git push origin my-new-feature`)
94
- 5. Create new Pull Request
104
+ 5. Create new Pull Request
@@ -5,8 +5,11 @@ module Zertico
5
5
  end
6
6
 
7
7
  def self.find(id)
8
- instance_variable_set("@#{interface_name}", interface_class.find(id))
9
- self
8
+ new(interface_class.find(id))
9
+ end
10
+
11
+ def interface
12
+ instance_variable_get("@#{interface_name}")
10
13
  end
11
14
 
12
15
  def method_missing(method_name, *args)
@@ -1,3 +1,3 @@
1
1
  module Zertico
2
- VERSION = '0.3.0'
2
+ VERSION = '0.3.1'
3
3
  end
@@ -2,6 +2,7 @@ require 'spec_helper'
2
2
 
3
3
  describe Zertico::Accessor do
4
4
  let(:user) { User.new }
5
+ let(:user_accessor) { UserAccessor.new(user) }
5
6
 
6
7
  describe '.initialize' do
7
8
  it 'should initialize the interface object on a instance variable' do
@@ -12,10 +13,21 @@ describe Zertico::Accessor do
12
13
  describe '.find' do
13
14
  before :each do
14
15
  User.stub(:find => user)
16
+ UserAccessor.stub(:new => user_accessor)
15
17
  end
16
18
 
17
- it 'should initialize the interface object on a instance variable' do
18
- UserAccessor.find(3).instance_variable_get('@user').should == user
19
+ it 'should return an accessor' do
20
+ UserAccessor.find(3).should == user_accessor
21
+ end
22
+ end
23
+
24
+ describe '#interface' do
25
+ before :each do
26
+ User.stub(:find => user)
27
+ end
28
+
29
+ it 'should return the interface object' do
30
+ UserAccessor.find(3).interface.should == user
19
31
  end
20
32
  end
21
33
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zertico
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-06-05 00:00:00.000000000 Z
12
+ date: 2013-06-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -107,7 +107,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
107
107
  version: '0'
108
108
  segments:
109
109
  - 0
110
- hash: 1292267407537345106
110
+ hash: -306725769998279200
111
111
  required_rubygems_version: !ruby/object:Gem::Requirement
112
112
  none: false
113
113
  requirements:
@@ -116,7 +116,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
116
116
  version: '0'
117
117
  segments:
118
118
  - 0
119
- hash: 1292267407537345106
119
+ hash: -306725769998279200
120
120
  requirements: []
121
121
  rubyforge_project:
122
122
  rubygems_version: 1.8.25