simple_model 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.md ADDED
@@ -0,0 +1,85 @@
1
+ # SimpleModel
2
+
3
+ ## Installation
4
+
5
+
6
+ SimpleModel is available through [Rubygems](http://rubygems.org/gems/simple_model) and can be installed via:
7
+
8
+ $ gem install simple_model
9
+
10
+ ## Usage
11
+ ### Basic
12
+ require 'simple_model'
13
+
14
+ class Item < SimpleModel::Base
15
+ has_booleans :active, :default => true
16
+ has_booleans :paid
17
+ has_currency :price, :default => 10.0
18
+ has_dates :created_at
19
+
20
+ private
21
+ def validate
22
+ validates_inclusion_of :price, :in => 10..25
23
+ end
24
+ end
25
+
26
+ item = Item.new(:created_at => "12/30/2010")
27
+ item.created_at # => #<Date: 2010-12-30 (4911121/2,0,2299161)>
28
+ item.active # => true
29
+ item.paid # => nil
30
+ item.paid? # => false
31
+ item.price # => 10.0
32
+ item.price = '$1,024.00'
33
+ item.price # => 1024.0
34
+ item.valid? # => false
35
+
36
+ ### Validation and Errors only
37
+
38
+ require 'simple_model'
39
+
40
+ class Item
41
+ include SimpleModel::Validation
42
+ include SimpleModel::Errors
43
+
44
+ attr_accessor :foo
45
+
46
+ private
47
+ def validate
48
+ validates_presence_of :foo
49
+ end
50
+ end
51
+
52
+ item = Item.new
53
+ item.valid? # => false
54
+
55
+ ### Validation Only - helpful if your class already has an errors object, but lacks built in validation
56
+
57
+ require 'simple_model'
58
+
59
+ class Item < SimpleRecord::Base
60
+ include SimpleModel::Validation
61
+
62
+ attr_accessor :foo
63
+
64
+ private
65
+ def validate
66
+ validates_presence_of :foo
67
+ end
68
+ end
69
+
70
+ item = Item.new
71
+ item.valid? # => false
72
+
73
+ ## Contributing to simple_model
74
+
75
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
76
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
77
+ * Fork the project
78
+ * Start a feature/bugfix branch
79
+ * Commit and push until you are happy with your contribution
80
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
81
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
82
+
83
+ ## Thanks
84
+
85
+ Code based on Rails/ActiveRecord and [Appoxy/SimpleRecord](https://github.com/appoxy/simple_record)
@@ -74,7 +74,7 @@ module SimpleModel
74
74
  full_messages = []
75
75
  errors.each do |error|
76
76
  error[1].each do |message|
77
- full_messages << "#{error[0].titleize} #{message}"
77
+ full_messages << "#{error[0].to_s} #{message}"
78
78
  end
79
79
  end
80
80
  full_messages
@@ -1,5 +1,4 @@
1
1
  module ExtendCore
2
-
3
2
  require 'time'
4
3
  require 'date'
5
4
 
@@ -61,6 +61,6 @@ module SimpleModel
61
61
  return true unless ((options[:if].blank? && options[:unless].blank?) ||
62
62
  !options[:if].blank? && send(options[:if])) ||
63
63
  (!options[:unless].blank? && !send(options[:unless]))
64
- end
64
+ end
65
65
  end
66
66
  end
@@ -1,3 +1,3 @@
1
1
  module SimpleModel
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 1
9
- version: 0.1.1
8
+ - 2
9
+ version: 0.1.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Joshua T Mckinney
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-12-28 00:00:00 -06:00
17
+ date: 2010-12-30 00:00:00 -06:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -46,7 +46,7 @@ files:
46
46
  - .gitignore
47
47
  - Gemfile
48
48
  - LICENSE.txt
49
- - README.rdoc
49
+ - README.md
50
50
  - Rakefile
51
51
  - lib/simple_model.rb
52
52
  - lib/simple_model/attributes.rb
data/README.rdoc DELETED
@@ -1,19 +0,0 @@
1
- = simple_model
2
-
3
- Testing
4
-
5
- == Contributing to simple_model
6
-
7
- * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
8
- * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
9
- * Fork the project
10
- * Start a feature/bugfix branch
11
- * Commit and push until you are happy with your contribution
12
- * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
13
- * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
14
-
15
- == Copyright
16
-
17
- Copyright (c) 2010 Joshua T. Mckinney. See LICENSE.txt for
18
- further details.
19
-