relaxo-model 0.3.9 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +4 -0
- data/README.md +7 -5
- data/lib/relaxo/model/document.rb +5 -3
- data/lib/relaxo/model/properties/attribute.rb +1 -0
- data/lib/relaxo/model/version.rb +1 -7
- data/rakefile.rb +1 -0
- data/relaxo-model.gemspec +29 -0
- metadata +54 -24
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 111d2212cc180cfad8ca53997c1a03722559694b
|
4
|
+
data.tar.gz: 5b37cb150db297bd854dca03c63101e9421f01a5
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 41532378165e1cbe27bd01ad15ca6274ab2c91c0d84f359af78cc0f83996d165692fc47cd228443f69e90a8d53d986d6d545f3b3588346c3fb618f71b17ebf2a
|
7
|
+
data.tar.gz: 9711fc150ce1e2b82f72b6249d193c84b73485ac175927c560697d3a768ff8785763dabdba2a690a9ab6554deeb888a1bbb383c04c17b40c5d34c45672a53382
|
data/Gemfile
ADDED
data/README.md
CHANGED
@@ -7,6 +7,8 @@ Relaxo Model
|
|
7
7
|
|
8
8
|
Relaxo Model provides a framework for business logic on top of Relaxo/CouchDB. While it supports some traditional ORM style patterns, it is primary focus is to model business processes and logic.
|
9
9
|
|
10
|
+
* This framework is pretty experimental right now and subject to change. Incompatible changes will be marked by the version number `x.y.z`, where changes in `x` indiciate fundamental API changes and changes in `y` indicate minor changes or additions that shouldn't cause breakage. *
|
11
|
+
|
10
12
|
Basic Usage
|
11
13
|
-----------
|
12
14
|
|
@@ -15,9 +17,9 @@ Here is a simple example of a traditional ORM style model:
|
|
15
17
|
require 'relaxo'
|
16
18
|
require 'relaxo/model'
|
17
19
|
|
18
|
-
|
20
|
+
database = Relaxo.connect("http://localhost:5984/test")
|
19
21
|
|
20
|
-
|
22
|
+
trees = [
|
21
23
|
{:name => 'Hinoki', :planted => Date.parse("1948/4/2")},
|
22
24
|
{:name => 'Rimu', :planted => Date.parse("1962/8/7")}
|
23
25
|
]
|
@@ -32,13 +34,13 @@ Here is a simple example of a traditional ORM style model:
|
|
32
34
|
view :all, 'catalog/tree', Tree
|
33
35
|
end
|
34
36
|
|
35
|
-
|
36
|
-
tree = Tree.create(
|
37
|
+
trees.each do |doc|
|
38
|
+
tree = Tree.create(database, doc)
|
37
39
|
|
38
40
|
tree.save
|
39
41
|
end
|
40
42
|
|
41
|
-
Tree.all(
|
43
|
+
Tree.all(database).each do |tree|
|
42
44
|
puts "A #{tree.name} was planted on #{tree.planted.to_s}."
|
43
45
|
|
44
46
|
# Expected output:
|
@@ -40,12 +40,12 @@ module Relaxo
|
|
40
40
|
TYPE = 'type'
|
41
41
|
|
42
42
|
def self.included(child)
|
43
|
-
# $stderr.puts "#{self} included -> #{child} extend ClassMethods"
|
44
43
|
child.send(:include, Component)
|
45
44
|
child.send(:extend, ClassMethods)
|
46
45
|
end
|
47
46
|
|
48
47
|
module ClassMethods
|
48
|
+
# Create a new document with a particular specified type.
|
49
49
|
def create(database, properties = nil)
|
50
50
|
instance = self.new(database, {TYPE => @type})
|
51
51
|
|
@@ -60,6 +60,7 @@ module Relaxo
|
|
60
60
|
return instance
|
61
61
|
end
|
62
62
|
|
63
|
+
# Fetch a record or create a model object from a hash of attributes.
|
63
64
|
def fetch(database, id_or_attributes)
|
64
65
|
if Hash === id_or_attributes
|
65
66
|
instance = self.new(database, id_or_attributes)
|
@@ -98,8 +99,8 @@ module Relaxo
|
|
98
99
|
def after_save
|
99
100
|
end
|
100
101
|
|
101
|
-
#
|
102
|
-
def
|
102
|
+
# Duplicate the model object, and possibly change the database it is connected to. You will potentially have two objects referring to the same record.
|
103
|
+
def dup(database = @database)
|
103
104
|
clone = self.class.new(database, @attributes.dup)
|
104
105
|
|
105
106
|
clone.after_fetch
|
@@ -107,6 +108,7 @@ module Relaxo
|
|
107
108
|
return clone
|
108
109
|
end
|
109
110
|
|
111
|
+
# Save the model object, raises `ValidationErrors` if there are validation errors.
|
110
112
|
def save
|
111
113
|
before_save
|
112
114
|
|
data/lib/relaxo/model/version.rb
CHANGED
data/rakefile.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'relaxo/model/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "relaxo-model"
|
8
|
+
spec.version = Relaxo::Model::VERSION
|
9
|
+
spec.authors = ["Samuel Williams"]
|
10
|
+
spec.email = ["samuel.williams@oriontransfer.co.nz"]
|
11
|
+
spec.description = <<-EOF
|
12
|
+
Relaxo Model provides a framework for business logic on top of
|
13
|
+
Relaxo/CouchDB. While it supports some traditional ORM style patterns, it is
|
14
|
+
primary focus is to model business processes and logic.
|
15
|
+
EOF
|
16
|
+
spec.summary = "A model layer for CouchDB with minimal global state."
|
17
|
+
spec.homepage = "http://www.codeotaku.com/projects/relaxo/model"
|
18
|
+
spec.license = "MIT"
|
19
|
+
|
20
|
+
spec.files = `git ls-files`.split($/)
|
21
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
22
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
23
|
+
spec.require_paths = ["lib"]
|
24
|
+
|
25
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
26
|
+
spec.add_development_dependency "rake"
|
27
|
+
|
28
|
+
spec.add_dependency("relaxo", "~> 0.4.0")
|
29
|
+
end
|
metadata
CHANGED
@@ -1,74 +1,104 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: relaxo-model
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.4.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Samuel Williams
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2013-08-01 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
|
-
name:
|
14
|
+
name: bundler
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
20
32
|
- !ruby/object:Gem::Version
|
21
33
|
version: '0'
|
22
|
-
type: :
|
34
|
+
type: :development
|
23
35
|
prerelease: false
|
24
36
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
37
|
requirements:
|
27
|
-
- -
|
38
|
+
- - '>='
|
28
39
|
- !ruby/object:Gem::Version
|
29
40
|
version: '0'
|
30
|
-
|
31
|
-
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: relaxo
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 0.4.0
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.4.0
|
55
|
+
description: "\t\tRelaxo Model provides a framework for business logic on top of\n\t\tRelaxo/CouchDB.
|
56
|
+
While it supports some traditional ORM style patterns, it is\n\t\tprimary focus
|
57
|
+
is to model business processes and logic.\n"
|
58
|
+
email:
|
59
|
+
- samuel.williams@oriontransfer.co.nz
|
32
60
|
executables: []
|
33
61
|
extensions: []
|
34
62
|
extra_rdoc_files: []
|
35
63
|
files:
|
64
|
+
- Gemfile
|
65
|
+
- README.md
|
66
|
+
- lib/relaxo/model.rb
|
36
67
|
- lib/relaxo/model/base.rb
|
37
68
|
- lib/relaxo/model/component.rb
|
38
69
|
- lib/relaxo/model/document.rb
|
70
|
+
- lib/relaxo/model/properties.rb
|
39
71
|
- lib/relaxo/model/properties/attribute.rb
|
40
72
|
- lib/relaxo/model/properties/bcrypt.rb
|
41
73
|
- lib/relaxo/model/properties/bigdecimal.rb
|
42
74
|
- lib/relaxo/model/properties/composite.rb
|
43
75
|
- lib/relaxo/model/properties/latinum.rb
|
44
|
-
- lib/relaxo/model/properties.rb
|
45
76
|
- lib/relaxo/model/recordset.rb
|
46
77
|
- lib/relaxo/model/version.rb
|
47
|
-
-
|
48
|
-
-
|
49
|
-
homepage: http://www.
|
50
|
-
licenses:
|
78
|
+
- rakefile.rb
|
79
|
+
- relaxo-model.gemspec
|
80
|
+
homepage: http://www.codeotaku.com/projects/relaxo/model
|
81
|
+
licenses:
|
82
|
+
- MIT
|
83
|
+
metadata: {}
|
51
84
|
post_install_message:
|
52
85
|
rdoc_options: []
|
53
86
|
require_paths:
|
54
87
|
- lib
|
55
88
|
required_ruby_version: !ruby/object:Gem::Requirement
|
56
|
-
none: false
|
57
89
|
requirements:
|
58
|
-
- -
|
90
|
+
- - '>='
|
59
91
|
- !ruby/object:Gem::Version
|
60
92
|
version: '0'
|
61
93
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
62
|
-
none: false
|
63
94
|
requirements:
|
64
|
-
- -
|
95
|
+
- - '>='
|
65
96
|
- !ruby/object:Gem::Version
|
66
97
|
version: '0'
|
67
98
|
requirements: []
|
68
99
|
rubyforge_project:
|
69
|
-
rubygems_version:
|
100
|
+
rubygems_version: 2.0.6
|
70
101
|
signing_key:
|
71
|
-
specification_version:
|
72
|
-
summary:
|
102
|
+
specification_version: 4
|
103
|
+
summary: A model layer for CouchDB with minimal global state.
|
73
104
|
test_files: []
|
74
|
-
has_rdoc:
|