supermodel 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/README +1 -1
- data/VERSION +1 -1
- data/lib/supermodel/base.rb +5 -1
- data/lib/supermodel/callbacks.rb +7 -4
- data/lib/supermodel/scriber.rb +16 -13
- data/supermodel.gemspec +2 -2
- metadata +2 -2
data/.gitignore
CHANGED
data/README
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.2
|
data/lib/supermodel/base.rb
CHANGED
@@ -154,6 +154,10 @@ module SuperModel
|
|
154
154
|
load(attributes) && save
|
155
155
|
end
|
156
156
|
|
157
|
+
def has_attribute?(name)
|
158
|
+
@attributes.has_key?(name)
|
159
|
+
end
|
160
|
+
|
157
161
|
alias_method :respond_to_without_attributes?, :respond_to?
|
158
162
|
|
159
163
|
def respond_to?(method, include_priv = false)
|
@@ -225,6 +229,6 @@ module SuperModel
|
|
225
229
|
class Base
|
226
230
|
extend ActiveModel::Naming
|
227
231
|
include ActiveModel::Conversion
|
228
|
-
include Observing, Validations,
|
232
|
+
include Observing, Validations, Callbacks
|
229
233
|
end
|
230
234
|
end
|
data/lib/supermodel/callbacks.rb
CHANGED
@@ -1,15 +1,18 @@
|
|
1
1
|
module SuperModel
|
2
2
|
module Callbacks
|
3
3
|
extend ActiveSupport::Concern
|
4
|
-
|
5
|
-
|
4
|
+
|
6
5
|
included do
|
7
|
-
|
6
|
+
instance_eval do
|
7
|
+
extend ActiveModel::Callbacks
|
8
|
+
define_model_callbacks :create, :save, :update, :destroy
|
9
|
+
end
|
10
|
+
|
8
11
|
%w( create save update destroy ).each do |method|
|
9
12
|
class_eval(<<-EOS, __FILE__, __LINE__ + 1)
|
10
13
|
def #{method}_with_callbacks(*args, &block)
|
11
14
|
_run_#{method}_callbacks do
|
12
|
-
#{method}
|
15
|
+
#{method}_without_callbacks(*args, &block)
|
13
16
|
end
|
14
17
|
end
|
15
18
|
EOS
|
data/lib/supermodel/scriber.rb
CHANGED
@@ -28,23 +28,26 @@ module SuperModel
|
|
28
28
|
end
|
29
29
|
|
30
30
|
module Model
|
31
|
-
def self.
|
31
|
+
def self.included(base)
|
32
32
|
Scriber.klasses << base
|
33
|
+
base.extend ClassMethods
|
33
34
|
end
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
35
|
+
|
36
|
+
module ClassMethods
|
37
|
+
def scribe_play(type, data) #:nodoc:
|
38
|
+
case type
|
39
|
+
when :create then create(data)
|
40
|
+
when :destroy then destroy(data)
|
41
|
+
when :update then update(data)
|
42
|
+
else
|
43
|
+
method = "scribe_play_#{type}"
|
44
|
+
send(method) if respond_to?(method)
|
45
|
+
end
|
43
46
|
end
|
44
|
-
end
|
45
47
|
|
46
|
-
|
47
|
-
|
48
|
+
def record(type, data)
|
49
|
+
::Scriber.record(self, type, data)
|
50
|
+
end
|
48
51
|
end
|
49
52
|
end
|
50
53
|
end
|
data/supermodel.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{supermodel}
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Alex MacCaw"]
|
12
|
-
s.date = %q{2010-02-
|
12
|
+
s.date = %q{2010-02-06}
|
13
13
|
s.description = %q{In memory DB using ActiveModel}
|
14
14
|
s.email = %q{info@eribium.org}
|
15
15
|
s.extra_rdoc_files = [
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: supermodel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex MacCaw
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-02-
|
12
|
+
date: 2010-02-06 00:00:00 +00:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|