acts_as_activitable 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/Gemfile +4 -0
- data/Rakefile +2 -0
- data/acts_as_activitable.gemspec +21 -0
- data/lib/acts_as_activitable.rb +61 -0
- data/lib/acts_as_activitable/version.rb +3 -0
- metadata +62 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "acts_as_activitable/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "acts_as_activitable"
|
7
|
+
s.version = ActsAsActivitable::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["Gunner Technology, Cody Swann"]
|
10
|
+
s.email = ["developers@gunnertech.com"]
|
11
|
+
s.homepage = ""
|
12
|
+
s.summary = %q{This gem will help you create a Facebook-like activity stream}
|
13
|
+
s.description = %q{acts_as_activitable is a gem that creates a database schema, methods and relationships for creating Facebook-like activity stream functionality}
|
14
|
+
|
15
|
+
s.rubyforge_project = "acts_as_activitable"
|
16
|
+
|
17
|
+
s.files = `git ls-files`.split("\n")
|
18
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
19
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
20
|
+
s.require_paths = ["lib"]
|
21
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
module ActsAsActivitable
|
2
|
+
def self.included(base)
|
3
|
+
base.extend ClassMethods
|
4
|
+
end
|
5
|
+
|
6
|
+
module ClassMethods
|
7
|
+
def acts_as_activitable
|
8
|
+
has_many :activities, :as => :activitable, :dependent => :destroy
|
9
|
+
|
10
|
+
after_create :create_activity
|
11
|
+
|
12
|
+
include ActsAsActivitable::InstanceMethods
|
13
|
+
extend ActsAsActivitable::SingletonMethods
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
module SingletonMethods
|
18
|
+
def exclude_from_activities
|
19
|
+
@@exclude_from_activities
|
20
|
+
end
|
21
|
+
|
22
|
+
def exclude_from_activities(attribute_hash)
|
23
|
+
@@exclude_from_activities = attribute_hash
|
24
|
+
end
|
25
|
+
|
26
|
+
def methods_for_activities
|
27
|
+
@@methods_for_activities
|
28
|
+
end
|
29
|
+
|
30
|
+
def methods_for_activities(method_hash)
|
31
|
+
@@methods_for_activities = method_hash
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
module InstanceMethods
|
36
|
+
|
37
|
+
def activity_owner
|
38
|
+
user
|
39
|
+
end
|
40
|
+
|
41
|
+
def create_activity
|
42
|
+
self.activities.create(:user => activity_owner, :data => self.to_activity_data)
|
43
|
+
end
|
44
|
+
|
45
|
+
def to_activity_data
|
46
|
+
attrs = self.attributes.symbolize_keys
|
47
|
+
attrs.delete(:id)
|
48
|
+
self.class.exclude_from_activities.each do |attribute|
|
49
|
+
attrs.delete(attribute.to_sym)
|
50
|
+
end
|
51
|
+
self.class.methods_for_activities.each do |method_name|
|
52
|
+
attrs[method_name.so_sym] = self.send(method_name.to_sym)
|
53
|
+
end
|
54
|
+
|
55
|
+
attrs
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
class Engine < ::Rails::Engine
|
60
|
+
end
|
61
|
+
end
|
metadata
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: acts_as_activitable
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 0.0.1
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Gunner Technology, Cody Swann
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2011-03-06 00:00:00 -08:00
|
14
|
+
default_executable:
|
15
|
+
dependencies: []
|
16
|
+
|
17
|
+
description: acts_as_activitable is a gem that creates a database schema, methods and relationships for creating Facebook-like activity stream functionality
|
18
|
+
email:
|
19
|
+
- developers@gunnertech.com
|
20
|
+
executables: []
|
21
|
+
|
22
|
+
extensions: []
|
23
|
+
|
24
|
+
extra_rdoc_files: []
|
25
|
+
|
26
|
+
files:
|
27
|
+
- .gitignore
|
28
|
+
- Gemfile
|
29
|
+
- Rakefile
|
30
|
+
- acts_as_activitable.gemspec
|
31
|
+
- lib/acts_as_activitable.rb
|
32
|
+
- lib/acts_as_activitable/version.rb
|
33
|
+
has_rdoc: true
|
34
|
+
homepage: ""
|
35
|
+
licenses: []
|
36
|
+
|
37
|
+
post_install_message:
|
38
|
+
rdoc_options: []
|
39
|
+
|
40
|
+
require_paths:
|
41
|
+
- lib
|
42
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
43
|
+
none: false
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: "0"
|
48
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: "0"
|
54
|
+
requirements: []
|
55
|
+
|
56
|
+
rubyforge_project: acts_as_activitable
|
57
|
+
rubygems_version: 1.6.0
|
58
|
+
signing_key:
|
59
|
+
specification_version: 3
|
60
|
+
summary: This gem will help you create a Facebook-like activity stream
|
61
|
+
test_files: []
|
62
|
+
|