honesty 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/honesty.rb +36 -37
- data/lib/honesty/version.rb +1 -1
- metadata +7 -7
data/lib/honesty.rb
CHANGED
@@ -5,48 +5,47 @@ require 'active_record'
|
|
5
5
|
module ActiveRecord; module Acts; end; end
|
6
6
|
module ActiveRecord::Acts::Honesty
|
7
7
|
|
8
|
-
|
9
|
-
|
8
|
+
def self.included(base)
|
9
|
+
base.extend ClassMethods
|
10
|
+
end
|
11
|
+
|
12
|
+
module ClassMethods
|
13
|
+
def honesty
|
14
|
+
has_many :truths, :as => :honesty, :dependent => :destroy, :order => 'created_at ASC'
|
15
|
+
include ActiveRecord::Acts::Honesty::InstanceMethods
|
10
16
|
end
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
+
end
|
18
|
+
|
19
|
+
module InstanceMethods
|
20
|
+
def truth(context, agent, action)
|
21
|
+
truth = Truth.new
|
22
|
+
truth.context = context
|
23
|
+
truth.agent = agent
|
24
|
+
truth.action = action
|
25
|
+
self.truths << truth
|
17
26
|
end
|
18
27
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
:conditions => ["agent = ?", self.class.agent],
|
38
|
-
:order => "created_at DESC"
|
39
|
-
)
|
40
|
-
end
|
41
|
-
def truths_by_action
|
42
|
-
Truth.find(:all,
|
43
|
-
:conditions => ["action = ?", self.class.action],
|
44
|
-
:order => "created_at DESC"
|
45
|
-
)
|
46
|
-
end
|
28
|
+
# Helper methods
|
29
|
+
def truths_by_context
|
30
|
+
Truth.find(:all,
|
31
|
+
:conditions => ["context = ?", self.class.context],
|
32
|
+
:order => "created_at DESC"
|
33
|
+
)
|
34
|
+
end
|
35
|
+
def truths_by_agent
|
36
|
+
Truth.find(:all,
|
37
|
+
:conditions => ["agent = ?", self.class.agent],
|
38
|
+
:order => "created_at DESC"
|
39
|
+
)
|
40
|
+
end
|
41
|
+
def truths_by_action
|
42
|
+
Truth.find(:all,
|
43
|
+
:conditions => ["action = ?", self.class.action],
|
44
|
+
:order => "created_at DESC"
|
45
|
+
)
|
47
46
|
end
|
48
|
-
|
49
47
|
end
|
48
|
+
|
50
49
|
end
|
51
50
|
|
52
51
|
ActiveRecord::Base.send(:include, ActiveRecord::Acts::Honesty)
|
data/lib/honesty/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: honesty
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2012-01-24 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
16
|
-
requirement: &
|
16
|
+
requirement: &70121415537040 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70121415537040
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: sqlite3
|
27
|
-
requirement: &
|
27
|
+
requirement: &70121415535960 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70121415535960
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rails
|
38
|
-
requirement: &
|
38
|
+
requirement: &70121415534220 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,7 +43,7 @@ dependencies:
|
|
43
43
|
version: '3.0'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70121415534220
|
47
47
|
description: Honesty allows developers to store and track user activities and system
|
48
48
|
events in a human-readable, easily-searchable format.
|
49
49
|
email:
|