yeti 0.1.6 → 0.1.7

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/lib/yeti/editor.rb CHANGED
@@ -75,6 +75,12 @@ module Yeti
75
75
  errors.empty?
76
76
  end
77
77
 
78
+ def mandatory?(column)
79
+ self.class.validators_on(column).any? do |validator|
80
+ validator.kind_of? ::ActiveModel::Validations::PresenceValidator
81
+ end
82
+ end
83
+
78
84
  private
79
85
 
80
86
  attr_reader :given_id
data/lib/yeti/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Yeti
2
- VERSION = "0.1.6"
2
+ VERSION = "0.1.7"
3
3
  end
@@ -221,4 +221,23 @@ describe Yeti::Editor do
221
221
  lambda{ subject.invalid }.should raise_error NoMethodError
222
222
  end
223
223
  end
224
+ describe "#mandatory?" do
225
+ let :editor_class do
226
+ Class.new Yeti::Editor do
227
+ validates_presence_of :name
228
+ attribute :name
229
+ attribute :password
230
+ end
231
+ end
232
+ subject{ editor_class.new context }
233
+ it "is true for an attribute with validates_presence_of" do
234
+ subject.mandatory?(:name).should be true
235
+ end
236
+ it "is false for an attribute without validates_presence_of" do
237
+ subject.mandatory?(:password).should be false
238
+ end
239
+ it "is false for an invalid attribute" do
240
+ subject.mandatory?(:invalid).should be false
241
+ end
242
+ end
224
243
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yeti
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
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: 2012-11-22 00:00:00.000000000 Z
12
+ date: 2012-11-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activemodel
@@ -112,18 +112,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
112
112
  - - ! '>='
113
113
  - !ruby/object:Gem::Version
114
114
  version: '0'
115
- segments:
116
- - 0
117
- hash: -532776958543363223
118
115
  required_rubygems_version: !ruby/object:Gem::Requirement
119
116
  none: false
120
117
  requirements:
121
118
  - - ! '>='
122
119
  - !ruby/object:Gem::Version
123
120
  version: '0'
124
- segments:
125
- - 0
126
- hash: -532776958543363223
127
121
  requirements: []
128
122
  rubyforge_project:
129
123
  rubygems_version: 1.8.24