cloudspace_chat_service 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.rspec +1 -0
- data/CHANGELOG +4 -0
- data/Gemfile +30 -0
- data/Gemfile.lock +160 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +19 -0
- data/Rakefile +45 -0
- data/VERSION +1 -0
- data/app/controllers/cloudspace_chat/handle_messages.rb +77 -0
- data/app/models/cloudspace_chat.rb +5 -0
- data/app/models/cloudspace_chat/current_room_user.rb +31 -0
- data/app/models/cloudspace_chat/message.rb +18 -0
- data/app/models/cloudspace_chat/role.rb +4 -0
- data/app/models/cloudspace_chat/room.rb +5 -0
- data/app/models/cloudspace_chat/room_user_role.rb +6 -0
- data/config/routes.rb +4 -0
- data/lib/cloudspace_chat_service.rb +2 -0
- data/lib/cloudspace_chat_service/config.rb +31 -0
- data/lib/cloudspace_chat_service/engine.rb +4 -0
- data/lib/cloudspace_chat_service/railtie.rb +8 -0
- data/lib/generators/cloudspace_chat_service/install_generator.rb +45 -0
- data/lib/generators/cloudspace_chat_service/templates/config.rb +3 -0
- data/lib/generators/cloudspace_chat_service/templates/migrations/install_migration.rb.erb +51 -0
- data/spec/dummy/Rakefile +7 -0
- data/spec/dummy/app/controllers/application_controller.rb +3 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/config/application.rb +45 -0
- data/spec/dummy/config/boot.rb +10 -0
- data/spec/dummy/config/database.yml +22 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +26 -0
- data/spec/dummy/config/environments/production.rb +49 -0
- data/spec/dummy/config/environments/test.rb +35 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/cloudspace_chat_service.rb +3 -0
- data/spec/dummy/config/initializers/inflections.rb +10 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +7 -0
- data/spec/dummy/config/initializers/session_store.rb +8 -0
- data/spec/dummy/config/locales/en.yml +5 -0
- data/spec/dummy/config/routes.rb +58 -0
- data/spec/dummy/db/migrate/20111101133120_create_cloudspace_chat_service_tables.rb +51 -0
- data/spec/dummy/db/schema.rb +55 -0
- data/spec/dummy/features/step_definitions/web_steps.rb +214 -0
- data/spec/dummy/features/support/env.rb +14 -0
- data/spec/dummy/features/support/paths.rb +22 -0
- data/spec/dummy/features/support/selectors.rb +39 -0
- data/spec/dummy/public/404.html +26 -0
- data/spec/dummy/public/422.html +26 -0
- data/spec/dummy/public/500.html +26 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/public/javascripts/application.js +2 -0
- data/spec/dummy/public/javascripts/controls.js +965 -0
- data/spec/dummy/public/javascripts/dragdrop.js +974 -0
- data/spec/dummy/public/javascripts/effects.js +1123 -0
- data/spec/dummy/public/javascripts/prototype.js +6001 -0
- data/spec/dummy/public/javascripts/rails.js +191 -0
- data/spec/dummy/public/stylesheets/.gitkeep +0 -0
- data/spec/dummy/script/rails +6 -0
- data/spec/models/current_room_user_spec.rb +105 -0
- data/spec/models/message_spec.rb +39 -0
- data/spec/models/role_spec.rb +13 -0
- data/spec/models/room_spec.rb +22 -0
- data/spec/models/room_user_role_spec.rb +13 -0
- data/spec/spec_helper.rb +39 -0
- data/spec/support/readme +1 -0
- metadata +292 -0
data/.document
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/CHANGELOG
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
# Add dependencies required to use your gem here.
|
3
|
+
# Example:
|
4
|
+
# gem "activesupport", ">= 2.3.5"
|
5
|
+
|
6
|
+
gem "rails", "3.0.7"
|
7
|
+
|
8
|
+
|
9
|
+
# Add dependencies to develop your gem here.
|
10
|
+
# Include everything needed to run rake, tests, features, etc.
|
11
|
+
group :development, :test do
|
12
|
+
|
13
|
+
gem "capybara", ">= 0.4.0"
|
14
|
+
gem "sqlite3"
|
15
|
+
|
16
|
+
gem 'ruby-debug19'
|
17
|
+
gem "rspec", "~> 2.6.0"
|
18
|
+
gem "rspec-rails", "~>2.6.1"
|
19
|
+
gem "shoulda"
|
20
|
+
gem "yard", "~> 0.6.0"
|
21
|
+
gem "cucumber", ">= 0"
|
22
|
+
gem "cucumber-rails"
|
23
|
+
gem "database_cleaner"
|
24
|
+
gem "bundler", "~> 1.0.0"
|
25
|
+
gem "jeweler", "~> 1.6.3"
|
26
|
+
gem "rcov", ">= 0"
|
27
|
+
|
28
|
+
# hudson ci
|
29
|
+
gem "ci_reporter"
|
30
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,160 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
abstract (1.0.0)
|
5
|
+
actionmailer (3.0.7)
|
6
|
+
actionpack (= 3.0.7)
|
7
|
+
mail (~> 2.2.15)
|
8
|
+
actionpack (3.0.7)
|
9
|
+
activemodel (= 3.0.7)
|
10
|
+
activesupport (= 3.0.7)
|
11
|
+
builder (~> 2.1.2)
|
12
|
+
erubis (~> 2.6.6)
|
13
|
+
i18n (~> 0.5.0)
|
14
|
+
rack (~> 1.2.1)
|
15
|
+
rack-mount (~> 0.6.14)
|
16
|
+
rack-test (~> 0.5.7)
|
17
|
+
tzinfo (~> 0.3.23)
|
18
|
+
activemodel (3.0.7)
|
19
|
+
activesupport (= 3.0.7)
|
20
|
+
builder (~> 2.1.2)
|
21
|
+
i18n (~> 0.5.0)
|
22
|
+
activerecord (3.0.7)
|
23
|
+
activemodel (= 3.0.7)
|
24
|
+
activesupport (= 3.0.7)
|
25
|
+
arel (~> 2.0.2)
|
26
|
+
tzinfo (~> 0.3.23)
|
27
|
+
activeresource (3.0.7)
|
28
|
+
activemodel (= 3.0.7)
|
29
|
+
activesupport (= 3.0.7)
|
30
|
+
activesupport (3.0.7)
|
31
|
+
archive-tar-minitar (0.5.2)
|
32
|
+
arel (2.0.10)
|
33
|
+
builder (2.1.2)
|
34
|
+
capybara (1.1.1)
|
35
|
+
mime-types (>= 1.16)
|
36
|
+
nokogiri (>= 1.3.3)
|
37
|
+
rack (>= 1.0.0)
|
38
|
+
rack-test (>= 0.5.4)
|
39
|
+
selenium-webdriver (~> 2.0)
|
40
|
+
xpath (~> 0.1.4)
|
41
|
+
childprocess (0.2.2)
|
42
|
+
ffi (~> 1.0.6)
|
43
|
+
ci_reporter (1.6.5)
|
44
|
+
builder (>= 2.1.2)
|
45
|
+
columnize (0.3.4)
|
46
|
+
cucumber (1.1.0)
|
47
|
+
builder (>= 2.1.2)
|
48
|
+
diff-lcs (>= 1.1.2)
|
49
|
+
gherkin (~> 2.5.0)
|
50
|
+
json (>= 1.4.6)
|
51
|
+
term-ansicolor (>= 1.0.6)
|
52
|
+
cucumber-rails (1.1.1)
|
53
|
+
capybara (>= 1.1.1)
|
54
|
+
cucumber (>= 1.1.0)
|
55
|
+
nokogiri (>= 1.5.0)
|
56
|
+
database_cleaner (0.6.7)
|
57
|
+
diff-lcs (1.1.3)
|
58
|
+
erubis (2.6.6)
|
59
|
+
abstract (>= 1.0.0)
|
60
|
+
ffi (1.0.9)
|
61
|
+
gherkin (2.5.4)
|
62
|
+
json (>= 1.4.6)
|
63
|
+
git (1.2.5)
|
64
|
+
i18n (0.5.0)
|
65
|
+
jeweler (1.6.4)
|
66
|
+
bundler (~> 1.0)
|
67
|
+
git (>= 1.2.5)
|
68
|
+
rake
|
69
|
+
json (1.6.1)
|
70
|
+
json_pure (1.6.1)
|
71
|
+
linecache19 (0.5.12)
|
72
|
+
ruby_core_source (>= 0.1.4)
|
73
|
+
mail (2.2.19)
|
74
|
+
activesupport (>= 2.3.6)
|
75
|
+
i18n (>= 0.4.0)
|
76
|
+
mime-types (~> 1.16)
|
77
|
+
treetop (~> 1.4.8)
|
78
|
+
mime-types (1.17.2)
|
79
|
+
nokogiri (1.5.0)
|
80
|
+
polyglot (0.3.2)
|
81
|
+
rack (1.2.4)
|
82
|
+
rack-mount (0.6.14)
|
83
|
+
rack (>= 1.0.0)
|
84
|
+
rack-test (0.5.7)
|
85
|
+
rack (>= 1.0)
|
86
|
+
rails (3.0.7)
|
87
|
+
actionmailer (= 3.0.7)
|
88
|
+
actionpack (= 3.0.7)
|
89
|
+
activerecord (= 3.0.7)
|
90
|
+
activeresource (= 3.0.7)
|
91
|
+
activesupport (= 3.0.7)
|
92
|
+
bundler (~> 1.0)
|
93
|
+
railties (= 3.0.7)
|
94
|
+
railties (3.0.7)
|
95
|
+
actionpack (= 3.0.7)
|
96
|
+
activesupport (= 3.0.7)
|
97
|
+
rake (>= 0.8.7)
|
98
|
+
thor (~> 0.14.4)
|
99
|
+
rake (0.9.2.2)
|
100
|
+
rcov (0.9.11)
|
101
|
+
rspec (2.6.0)
|
102
|
+
rspec-core (~> 2.6.0)
|
103
|
+
rspec-expectations (~> 2.6.0)
|
104
|
+
rspec-mocks (~> 2.6.0)
|
105
|
+
rspec-core (2.6.4)
|
106
|
+
rspec-expectations (2.6.0)
|
107
|
+
diff-lcs (~> 1.1.2)
|
108
|
+
rspec-mocks (2.6.0)
|
109
|
+
rspec-rails (2.6.1)
|
110
|
+
actionpack (~> 3.0)
|
111
|
+
activesupport (~> 3.0)
|
112
|
+
railties (~> 3.0)
|
113
|
+
rspec (~> 2.6.0)
|
114
|
+
ruby-debug-base19 (0.11.25)
|
115
|
+
columnize (>= 0.3.1)
|
116
|
+
linecache19 (>= 0.5.11)
|
117
|
+
ruby_core_source (>= 0.1.4)
|
118
|
+
ruby-debug19 (0.11.6)
|
119
|
+
columnize (>= 0.3.1)
|
120
|
+
linecache19 (>= 0.5.11)
|
121
|
+
ruby-debug-base19 (>= 0.11.19)
|
122
|
+
ruby_core_source (0.1.5)
|
123
|
+
archive-tar-minitar (>= 0.5.2)
|
124
|
+
rubyzip (0.9.4)
|
125
|
+
selenium-webdriver (2.9.1)
|
126
|
+
childprocess (>= 0.2.1)
|
127
|
+
ffi (= 1.0.9)
|
128
|
+
json_pure
|
129
|
+
rubyzip
|
130
|
+
shoulda (2.11.3)
|
131
|
+
sqlite3 (1.3.4)
|
132
|
+
term-ansicolor (1.0.7)
|
133
|
+
thor (0.14.6)
|
134
|
+
treetop (1.4.10)
|
135
|
+
polyglot
|
136
|
+
polyglot (>= 0.3.1)
|
137
|
+
tzinfo (0.3.30)
|
138
|
+
xpath (0.1.4)
|
139
|
+
nokogiri (~> 1.3)
|
140
|
+
yard (0.6.8)
|
141
|
+
|
142
|
+
PLATFORMS
|
143
|
+
ruby
|
144
|
+
|
145
|
+
DEPENDENCIES
|
146
|
+
bundler (~> 1.0.0)
|
147
|
+
capybara (>= 0.4.0)
|
148
|
+
ci_reporter
|
149
|
+
cucumber
|
150
|
+
cucumber-rails
|
151
|
+
database_cleaner
|
152
|
+
jeweler (~> 1.6.3)
|
153
|
+
rails (= 3.0.7)
|
154
|
+
rcov
|
155
|
+
rspec (~> 2.6.0)
|
156
|
+
rspec-rails (~> 2.6.1)
|
157
|
+
ruby-debug19
|
158
|
+
shoulda
|
159
|
+
sqlite3
|
160
|
+
yard (~> 0.6.0)
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011 Jeremiah Hemphill
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
= cloudspace_chat_service
|
2
|
+
|
3
|
+
Extenable chat service for cloudspace.
|
4
|
+
|
5
|
+
== Contributing to cloudspace_chat_service
|
6
|
+
|
7
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
|
8
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
|
9
|
+
* Fork the project
|
10
|
+
* Start a feature/bugfix branch
|
11
|
+
* Commit and push until you are happy with your contribution
|
12
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
13
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
14
|
+
|
15
|
+
== Copyright
|
16
|
+
|
17
|
+
Copyright (c) 2011 Jeremiah Hemphill. See LICENSE.txt for
|
18
|
+
further details.
|
19
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
begin
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
$stderr.puts e.message
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
+
exit e.status_code
|
11
|
+
end
|
12
|
+
require 'rake'
|
13
|
+
|
14
|
+
require 'jeweler'
|
15
|
+
Jeweler::Tasks.new do |gem|
|
16
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
17
|
+
gem.name = "cloudspace_chat_service"
|
18
|
+
gem.homepage = "http://github.com/jeremiahishere/cloudspace_chat_service"
|
19
|
+
gem.license = "MIT"
|
20
|
+
gem.summary = %Q{Extendable chat service for cloudspace}
|
21
|
+
gem.description = %Q{Extendable chat service for cloudspace}
|
22
|
+
gem.email = "jeremiah@cloudspace.com,epemble@cloudspace.com,adam@cloudspace.com"
|
23
|
+
gem.authors = ["Jeremiah Hemphill","Ethan Pemble","Adam Dunson"]
|
24
|
+
# dependencies defined in Gemfile
|
25
|
+
end
|
26
|
+
Jeweler::RubygemsDotOrgTasks.new
|
27
|
+
|
28
|
+
require 'rspec/core'
|
29
|
+
require 'rspec/core/rake_task'
|
30
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
31
|
+
spec.pattern = FileList['spec/**/*_spec.rb']
|
32
|
+
end
|
33
|
+
|
34
|
+
RSpec::Core::RakeTask.new(:rcov) do |spec|
|
35
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
36
|
+
spec.rcov = true
|
37
|
+
end
|
38
|
+
|
39
|
+
require 'cucumber/rake/task'
|
40
|
+
Cucumber::Rake::Task.new(:features)
|
41
|
+
|
42
|
+
task :default => :spec
|
43
|
+
|
44
|
+
require 'yard'
|
45
|
+
YARD::Rake::YardocTask.new
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.1
|
@@ -0,0 +1,77 @@
|
|
1
|
+
class CloudspaceChat::HandleMessages < ApplicationController
|
2
|
+
|
3
|
+
# connect a user and give them permission to post
|
4
|
+
def connect
|
5
|
+
@current_room_user = CloudspaceChat::CurrentRoomUser.find_by_user_id_and_room_id(current_user.id, params[:room_id])
|
6
|
+
if @current_room_user.nil?
|
7
|
+
@current_room_user = CloudspaceChat::CurrentRoomUser.create(
|
8
|
+
:room_id => params[:room_id],
|
9
|
+
:user_id => current_user.id,
|
10
|
+
:connected => false,
|
11
|
+
:allowed => true,
|
12
|
+
:banned => false)
|
13
|
+
end
|
14
|
+
|
15
|
+
current_room_user_hash = @current_room_user.connect_and_generate_hash
|
16
|
+
respond_to do |format|
|
17
|
+
if current_room_user_hash
|
18
|
+
format.json { render :json => { :user_hash => current_room_user_hash } }
|
19
|
+
else
|
20
|
+
format.json { render :json => { :error => "A user hash could not be created" } }
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def disconnect
|
26
|
+
@current_room_user = CloudspaceChat::CurrentRoomUser.find_by_user_hash(params[:user_hash])
|
27
|
+
@current_room_user.disconnect_user_and_remove_hash
|
28
|
+
end
|
29
|
+
|
30
|
+
# the user validation check on the hash should probably be done in a before filter
|
31
|
+
def send_message
|
32
|
+
@current_room_user = CloudspaceChat::CurrentRoomUser.find_by_user_hash(params[:user_hash])
|
33
|
+
|
34
|
+
respond_to do |format|
|
35
|
+
if @current_room_user.user_id == current_user.id
|
36
|
+
@message = CloudspaceChat::Message.new(:current_room_user_id => @current_room_user.id, :input_text => params[:message])
|
37
|
+
if(@message.save)
|
38
|
+
format.json { render :json => { :message_id => @message.id, :message_text => @message.output_text } }
|
39
|
+
else
|
40
|
+
format.json { render :json => { :error => "The message could not be saved." } }
|
41
|
+
end
|
42
|
+
else
|
43
|
+
format.json { render :json => { :error => "The user could not be found." } }
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
# the user validation check on the hash should probably be done in a before filter
|
49
|
+
def get_messages_since_timestamp(timestamp)
|
50
|
+
@current_room_user = CloudspaceChat::CurrentRoomUser.find_by_user_hash(params[:user_hash])
|
51
|
+
respond_to do |format|
|
52
|
+
if @current_room_user.user_id == current_user.id
|
53
|
+
if params[:timestamp] == "undefined"
|
54
|
+
created_at = 1.year.ago
|
55
|
+
else
|
56
|
+
created_at = Time.at(params[:timestamp].to_i/1000).localtime
|
57
|
+
end
|
58
|
+
|
59
|
+
# this could be written much better
|
60
|
+
@messages = CloudspaceChat::Message.created_after(created_at)
|
61
|
+
@output_messages = {}
|
62
|
+
@messages.each do |message|
|
63
|
+
# id is listed twice here becuase I am not sure which one will be more useful
|
64
|
+
@output_messages[message.id] = {
|
65
|
+
:id => message.id,
|
66
|
+
:text => message.output_text,
|
67
|
+
:user_name => message.current_room_user.user.name
|
68
|
+
}
|
69
|
+
end
|
70
|
+
|
71
|
+
format.json { render :json => @output_messages }
|
72
|
+
else
|
73
|
+
format.json { render :json => { :error => "The user could not be found." } }
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'active_support/secure_random'
|
2
|
+
|
3
|
+
class CloudspaceChat::CurrentRoomUser < ActiveRecord::Base
|
4
|
+
has_many :messages
|
5
|
+
has_many :room_user_roles
|
6
|
+
has_many :roles, :through => :room_user_roles
|
7
|
+
belongs_to :room
|
8
|
+
belongs_to :user
|
9
|
+
|
10
|
+
validates_presence_of :room_id, :user_id
|
11
|
+
validates_inclusion_of [:connected, :allowed, :banned], :in => [true, false]
|
12
|
+
|
13
|
+
# sets a user to connected unless banned and gives them a hash for posting
|
14
|
+
def connect_and_generate_hash
|
15
|
+
unless banned?
|
16
|
+
self.connected_hash = ActiveSupport::SecureRandom.base64(16)
|
17
|
+
self.connected = true
|
18
|
+
self.save
|
19
|
+
end
|
20
|
+
return self.connected_hash
|
21
|
+
end
|
22
|
+
|
23
|
+
# disconnects a user and removes the posting hash
|
24
|
+
#
|
25
|
+
# only disconnects the backend
|
26
|
+
def disconnect_and_remove_hash
|
27
|
+
self.connected = false
|
28
|
+
self.connected_hash = ""
|
29
|
+
self.save
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
class CloudspaceChat::Message < ActiveRecord::Base
|
2
|
+
belongs_to :current_room_user
|
3
|
+
|
4
|
+
before_validation :prepare_input_text
|
5
|
+
|
6
|
+
validates_presence_of :current_room_user_id, :input_text, :output_text
|
7
|
+
validates_inclusion_of :visible, :in => [true, false]
|
8
|
+
|
9
|
+
scope :created_after, lambda { |created_at| where(["cloudspace_chat_messages.created_at > ?", created_at]) }
|
10
|
+
|
11
|
+
# this function should be observed by gems that alter the state of the output text
|
12
|
+
# this is the base case
|
13
|
+
# input is copied to output without any changes and set to visible
|
14
|
+
def prepare_input_text
|
15
|
+
self.output_text = self.input_text
|
16
|
+
self.visible = true
|
17
|
+
end
|
18
|
+
end
|