edifice 0.10.0 → 0.10.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/edifice/form_model.rb +14 -0
- data/lib/edifice/version.rb +1 -1
- metadata +4 -4
data/lib/edifice/form_model.rb
CHANGED
@@ -6,6 +6,16 @@ module Edifice
|
|
6
6
|
include ActiveModel::Conversion
|
7
7
|
extend ActiveModel::Naming
|
8
8
|
|
9
|
+
# more or less the same as activerecord's one
|
10
|
+
class RecordInvalid < Exception
|
11
|
+
attr_reader :record
|
12
|
+
def initialize(record)
|
13
|
+
@model = record
|
14
|
+
errors = @record.errors.full_messages.join(", ")
|
15
|
+
super(errors)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
9
19
|
def initialize(attributes = {})
|
10
20
|
attributes.each { |n, v| send("#{n}=", v) if respond_to?("#{n}=") }
|
11
21
|
end
|
@@ -15,6 +25,10 @@ module Edifice
|
|
15
25
|
valid?
|
16
26
|
end
|
17
27
|
|
28
|
+
def save!
|
29
|
+
save || raise(RecordInvalid.new(self))
|
30
|
+
end
|
31
|
+
|
18
32
|
def self.create(attributes = {})
|
19
33
|
form = new(attributes)
|
20
34
|
form.save
|
data/lib/edifice/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: edifice
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 53
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 10
|
9
|
-
-
|
10
|
-
version: 0.10.
|
9
|
+
- 1
|
10
|
+
version: 0.10.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Tom Coleman
|
@@ -17,7 +17,7 @@ autorequire:
|
|
17
17
|
bindir: bin
|
18
18
|
cert_chain: []
|
19
19
|
|
20
|
-
date: 2011-11-
|
20
|
+
date: 2011-11-18 00:00:00 Z
|
21
21
|
dependencies: []
|
22
22
|
|
23
23
|
description: The idea here is to communicate which view is rendering to the javascript so that we can call the correct javascript files in an automagical way.
|