basic_model 0.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.
Files changed (4) hide show
  1. data/LICENSE +20 -0
  2. data/README.md +22 -0
  3. data/lib/basic_model.rb +17 -0
  4. metadata +101 -0
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2010 Peter Browne
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,22 @@
1
+ # BasicModel
2
+
3
+ BasicModel is intended to be used as a tableless model in Rails. It complies with the ActiveModel API and includes valdiations, so it can be used in form helpers without a problem.
4
+
5
+ ## Usage
6
+
7
+ gem install basic_model
8
+
9
+ # Gemfile
10
+ gem 'basic_model'
11
+
12
+ # models/message.rb
13
+ class Message < BasicModel
14
+ attr_accessor :name, :email, :content
15
+
16
+ # can even include validations
17
+ validates_presence_of :name
18
+ end
19
+
20
+ ## Copyright
21
+
22
+ Copyright (c) 2009 [Peter Browne](http://petebrowne.com). See LICENSE for details.
@@ -0,0 +1,17 @@
1
+ require 'active_model'
2
+
3
+ class BasicModel
4
+ include ActiveModel::Conversion
5
+ include ActiveModel::Validations
6
+ extend ActiveModel::Naming
7
+
8
+ def initialize(attributes = {})
9
+ attributes.each do |name, value|
10
+ send("#{name}=", value)
11
+ end unless attributes.nil?
12
+ end
13
+
14
+ def persisted?
15
+ false
16
+ end
17
+ end
metadata ADDED
@@ -0,0 +1,101 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: basic_model
3
+ version: !ruby/object:Gem::Version
4
+ hash: 9
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 1
9
+ version: "0.1"
10
+ platform: ruby
11
+ authors:
12
+ - Pete Browne
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2010-07-07 00:00:00 -05:00
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ requirement: &id001 !ruby/object:Gem::Requirement
22
+ none: false
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ hash: 299253624
27
+ segments:
28
+ - 3
29
+ - 0
30
+ - 0
31
+ - beta4
32
+ version: 3.0.0.beta4
33
+ type: :runtime
34
+ prerelease: false
35
+ name: activemodel
36
+ version_requirements: *id001
37
+ - !ruby/object:Gem::Dependency
38
+ requirement: &id002 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ hash: 299253624
44
+ segments:
45
+ - 3
46
+ - 0
47
+ - 0
48
+ - beta4
49
+ version: 3.0.0.beta4
50
+ type: :runtime
51
+ prerelease: false
52
+ name: activesupport
53
+ version_requirements: *id002
54
+ description: BasicModel is intended to be used as a tableless model in Rails. It complies with the ActiveModel API and includes valdiations, so it can be used in form helpers without a problem.
55
+ email: me@petebrowne.com
56
+ executables: []
57
+
58
+ extensions: []
59
+
60
+ extra_rdoc_files: []
61
+
62
+ files:
63
+ - lib/basic_model.rb
64
+ - LICENSE
65
+ - README.md
66
+ has_rdoc: true
67
+ homepage: http://github.com/petebrowne/basic_model
68
+ licenses: []
69
+
70
+ post_install_message:
71
+ rdoc_options: []
72
+
73
+ require_paths:
74
+ - lib
75
+ required_ruby_version: !ruby/object:Gem::Requirement
76
+ none: false
77
+ requirements:
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ hash: 3
81
+ segments:
82
+ - 0
83
+ version: "0"
84
+ required_rubygems_version: !ruby/object:Gem::Requirement
85
+ none: false
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ hash: 3
90
+ segments:
91
+ - 0
92
+ version: "0"
93
+ requirements: []
94
+
95
+ rubyforge_project: basic_model
96
+ rubygems_version: 1.3.7
97
+ signing_key:
98
+ specification_version: 3
99
+ summary: BasicModel is a tiny Class that complies with the ActiveModel API
100
+ test_files: []
101
+