Floppy-amee 0.4.12 → 0.4.13
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.
- data/lib/amee/rails.rb +46 -0
- data/lib/amee/version.rb +1 -1
- metadata +2 -2
data/lib/amee/rails.rb
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
module AMEE
|
|
2
|
+
module Rails
|
|
3
|
+
|
|
4
|
+
def self.included(base)
|
|
5
|
+
base.extend ClassMethods
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
module ClassMethods
|
|
9
|
+
def has_amee_profile(options = {})
|
|
10
|
+
# Include the instance methods for creation and desctruction
|
|
11
|
+
include InstanceMethods
|
|
12
|
+
# Install callbacks
|
|
13
|
+
before_validation_on_create :amee_create
|
|
14
|
+
before_save :amee_save
|
|
15
|
+
before_destroy :amee_destroy
|
|
16
|
+
# Check that this object has an AMEE profile UID when saving
|
|
17
|
+
validates_presence_of :amee_profile
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
module InstanceMethods
|
|
22
|
+
|
|
23
|
+
def amee_create
|
|
24
|
+
# Create profile
|
|
25
|
+
profile = AMEE::Profile::Profile.create(amee_connection)
|
|
26
|
+
self.amee_profile = profile.uid
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def amee_save
|
|
30
|
+
# This is only here to be overridden
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def amee_destroy
|
|
34
|
+
# Delete profile
|
|
35
|
+
AMEE::Profile::Profile.delete(amee_connection, amee_profile)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def amee_connection
|
|
39
|
+
# Should be overridden by code which doesn't use the global AMEE connection
|
|
40
|
+
$amee
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
end
|
|
46
|
+
end
|
data/lib/amee/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: Floppy-amee
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.4.
|
|
4
|
+
version: 0.4.13
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- James Smith
|
|
@@ -39,7 +39,7 @@ files:
|
|
|
39
39
|
- lib/amee/object.rb
|
|
40
40
|
- lib/amee/shell.rb
|
|
41
41
|
- lib/amee/drill_down.rb
|
|
42
|
-
- lib/rails.rb
|
|
42
|
+
- lib/amee/rails.rb
|
|
43
43
|
- bin/ameesh
|
|
44
44
|
- examples/list_profiles.rb
|
|
45
45
|
- examples/create_profile.rb
|