dm-dragonfly 0.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 (2) hide show
  1. data/lib/dm-dragonfly.rb +50 -0
  2. metadata +84 -0
@@ -0,0 +1,50 @@
1
+ require 'dragonfly'
2
+
3
+ module Dragonfly
4
+ module DataMapperExtensions
5
+ def self.extended(klass)
6
+ klass.extend(ClassMethods)
7
+ klass.extend(ActiveModelExtensions::ClassMethods)
8
+
9
+ klass.class_eval do
10
+ include InstanceMethods
11
+ include ActiveModelExtensions::InstanceMethods
12
+ end
13
+ end
14
+
15
+ module ClassMethods
16
+ def before_save(method)
17
+ unless hooks[:save][:before].map{|h| h.instance_variable_get(:@method)}.include?(method)
18
+ before(:save, method)
19
+ end
20
+ end
21
+
22
+ def before_destroy(method)
23
+ unless hooks[:destroy][:before].map{|h| h.instance_variable_get(:@method)}.include?(method)
24
+ before(:destroy, method)
25
+ end
26
+ end
27
+ end
28
+
29
+ module InstanceMethods
30
+ def dirty_self?
31
+ dragonfly_attachments.keys.any?{|k| !!send(k) && !send("#{k}_uid")} || super
32
+ end
33
+ end
34
+ end
35
+
36
+ class App
37
+ def define_dm_macro(mod, macro_name)
38
+ app = self
39
+ (class << mod; self; end).class_eval do
40
+ alias included_without_dragonfly included
41
+ define_method :included_with_dragonfly do |mod|
42
+ included_without_dragonfly(mod)
43
+ mod.extend(DataMapperExtensions)
44
+ mod.register_dragonfly_app(macro_name, app)
45
+ end
46
+ alias included included_with_dragonfly
47
+ end
48
+ end
49
+ end
50
+ end
metadata ADDED
@@ -0,0 +1,84 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: dm-dragonfly
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - Mike Richards
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-05-05 00:00:00 -07:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: dragonfly
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ hash: 59
30
+ segments:
31
+ - 0
32
+ - 9
33
+ - 0
34
+ version: 0.9.0
35
+ type: :runtime
36
+ version_requirements: *id001
37
+ description: DataMapper extensions to support Dragonfly
38
+ email: mike22e@gmail.com
39
+ executables: []
40
+
41
+ extensions: []
42
+
43
+ extra_rdoc_files: []
44
+
45
+ files:
46
+ - lib/dm-dragonfly.rb
47
+ has_rdoc: true
48
+ homepage: http://github.com/mikeric/dm-dragonfly
49
+ licenses: []
50
+
51
+ post_install_message:
52
+ rdoc_options: []
53
+
54
+ require_paths:
55
+ - lib
56
+ required_ruby_version: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ hash: 3
62
+ segments:
63
+ - 0
64
+ version: "0"
65
+ required_rubygems_version: !ruby/object:Gem::Requirement
66
+ none: false
67
+ requirements:
68
+ - - ~>
69
+ - !ruby/object:Gem::Version
70
+ hash: 15
71
+ segments:
72
+ - 1
73
+ - 6
74
+ - 0
75
+ version: 1.6.0
76
+ requirements: []
77
+
78
+ rubyforge_project:
79
+ rubygems_version: 1.6.2
80
+ signing_key:
81
+ specification_version: 3
82
+ summary: DataMapper extensions to support Dragonfly
83
+ test_files: []
84
+