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 CHANGED
@@ -1,2 +1,3 @@
1
1
  dump.db
2
2
  test.rb
3
+ pkg
data/README CHANGED
@@ -1,7 +1,7 @@
1
1
 
2
2
  Simple in-memory database using ActiveModel.
3
3
 
4
- Primarily developed for Bowline application.
4
+ Primarily developed for Bowline applications.
5
5
  http://github.com/maccman/bowline
6
6
 
7
7
  Supports:
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.1
1
+ 0.0.2
@@ -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, Scriber
232
+ include Observing, Validations, Callbacks
229
233
  end
230
234
  end
@@ -1,15 +1,18 @@
1
1
  module SuperModel
2
2
  module Callbacks
3
3
  extend ActiveSupport::Concern
4
- extend ActiveModel::Callbacks
5
-
4
+
6
5
  included do
7
- define_model_callbacks :create, :save, :update, :destroy
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}_without_notifications(*args, &block)
15
+ #{method}_without_callbacks(*args, &block)
13
16
  end
14
17
  end
15
18
  EOS
@@ -28,23 +28,26 @@ module SuperModel
28
28
  end
29
29
 
30
30
  module Model
31
- def self.extended(base)
31
+ def self.included(base)
32
32
  Scriber.klasses << base
33
+ base.extend ClassMethods
33
34
  end
34
-
35
- def scribe_load(type, data) #:nodoc:
36
- case type
37
- when :create then create(data)
38
- when :destroy then destroy(data)
39
- when :update then update(data)
40
- else
41
- method = "scribe_load_#{type}"
42
- send(method) if respond_to?(method)
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
- def record(type, data)
47
- ::Scriber.record(self, type, data)
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.1"
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-04}
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.1
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-04 00:00:00 +00:00
12
+ date: 2010-02-06 00:00:00 +00:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency