makena 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (76) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +37 -0
  3. data/Gemfile +139 -0
  4. data/Gemfile.lock +469 -0
  5. data/README.rdoc +28 -0
  6. data/Rakefile +6 -0
  7. data/app/assets/images/.keep +0 -0
  8. data/app/assets/javascripts/application.js +16 -0
  9. data/app/assets/stylesheets/application.css +13 -0
  10. data/app/controllers/application_controller.rb +5 -0
  11. data/app/controllers/concerns/.keep +0 -0
  12. data/app/helpers/application_helper.rb +2 -0
  13. data/app/mailers/.keep +0 -0
  14. data/app/models/.keep +0 -0
  15. data/app/models/concerns/.keep +0 -0
  16. data/app/views/layouts/application.html.erb +14 -0
  17. data/bin/bundle +3 -0
  18. data/bin/rails +4 -0
  19. data/bin/rake +4 -0
  20. data/config.ru +4 -0
  21. data/config/application.rb +23 -0
  22. data/config/boot.rb +4 -0
  23. data/config/database.yml +39 -0
  24. data/config/environment.rb +5 -0
  25. data/config/environments/development.rb +29 -0
  26. data/config/environments/production.rb +80 -0
  27. data/config/environments/test.rb +36 -0
  28. data/config/initializers/backtrace_silencers.rb +7 -0
  29. data/config/initializers/filter_parameter_logging.rb +4 -0
  30. data/config/initializers/inflections.rb +16 -0
  31. data/config/initializers/mime_types.rb +5 -0
  32. data/config/initializers/secret_token.rb +12 -0
  33. data/config/initializers/session_store.rb +3 -0
  34. data/config/initializers/wrap_parameters.rb +14 -0
  35. data/config/locales/en.yml +23 -0
  36. data/config/routes.rb +56 -0
  37. data/db/seeds.rb +7 -0
  38. data/lib/assets/.keep +0 -0
  39. data/lib/generators/connection/USAGE +26 -0
  40. data/lib/generators/connection/connection_generator.rb +195 -0
  41. data/lib/generators/connection/templates/extensions/alpha_alphas.rb +17 -0
  42. data/lib/generators/connection/templates/extensions/alpha_betas.rb +17 -0
  43. data/lib/generators/connection/templates/extensions/geocoder.rb +23 -0
  44. data/lib/generators/connection/templates/extensions/image.rb +12 -0
  45. data/lib/generators/copy/USAGE +7 -0
  46. data/lib/generators/copy/copy_generator.rb +41 -0
  47. data/lib/generators/git/USAGE +8 -0
  48. data/lib/generators/git/git_generator.rb +59 -0
  49. data/lib/generators/setup/USAGE +8 -0
  50. data/lib/generators/setup/setup_generator.rb +151 -0
  51. data/lib/generators/success/USAGE +44 -0
  52. data/lib/generators/success/success_generator.rb +18 -0
  53. data/lib/tasks/.keep +0 -0
  54. data/makena/.gitignore +17 -0
  55. data/makena/Gemfile +4 -0
  56. data/makena/LICENSE.txt +22 -0
  57. data/makena/README.md +32 -0
  58. data/makena/Rakefile +1 -0
  59. data/makena/lib/makena.rb +21 -0
  60. data/makena/lib/makena/controllers.rb +218 -0
  61. data/makena/lib/makena/gps.rb +2 -0
  62. data/makena/lib/makena/image.rb +2 -0
  63. data/makena/lib/makena/layouts.rb +41 -0
  64. data/makena/lib/makena/models.rb +2 -0
  65. data/makena/lib/makena/tree.rb +181 -0
  66. data/makena/lib/makena/version.rb +3 -0
  67. data/makena/lib/makena/views.rb +225 -0
  68. data/makena/makena.gemspec +23 -0
  69. data/public/404.html +58 -0
  70. data/public/422.html +58 -0
  71. data/public/500.html +57 -0
  72. data/public/favicon.ico +0 -0
  73. data/public/robots.txt +5 -0
  74. data/vendor/assets/javascripts/.keep +0 -0
  75. data/vendor/assets/stylesheets/.keep +0 -0
  76. metadata +150 -0
@@ -0,0 +1,8 @@
1
+ Description:
2
+ Explain the generator
3
+
4
+ Example:
5
+ rails generate makena Thing
6
+
7
+ This will create:
8
+ what/will/it/create
@@ -0,0 +1,151 @@
1
+ class SetupGenerator < Rails::Generators::NamedBase
2
+
3
+ # Root
4
+ source_root File.expand_path('../../../../../success', __FILE__)
5
+
6
+ def copy_readme
7
+ adapt_file("README.rdoc")
8
+ end
9
+
10
+ def copy_gitignore
11
+ copy_file ".gitignore"
12
+ end
13
+
14
+ def install_cucumber
15
+ run "rails g rspec:install"
16
+ run "rails g cucumber:install"
17
+ directory "features"
18
+ adapt_file("features/user.feature")
19
+ end
20
+
21
+ def copy_figaro
22
+ copy_file "config/application.yml"
23
+ adapt_file "config/application.yml"
24
+ end
25
+
26
+ def copy_fog
27
+ copy_file "config/initializers/fog.rb"
28
+ append_to_file "config/initializers/fog.rb",
29
+ "\n# #{"todo".upcase} add AWS bucket #{name.downcase}\n\n"
30
+ end
31
+
32
+ def copy_friendship
33
+ run "rails g scaffold friendships message:text deny:boolean:index meet_at:datetime:index address:string:index latitude:float:index longitude:float:index user:references friend:references"
34
+ end
35
+
36
+ def copy_uploaders
37
+ directory "app/uploaders"
38
+ end
39
+
40
+ def copy_layout
41
+ copy_file "app/assets/javascripts/application.js"
42
+ copy_file "app/assets/stylesheets/application.css"
43
+ directory "app/views/layouts"
44
+ copy_helper "apple"
45
+ copy_helper "controllers"
46
+ copy_helper "layouts"
47
+ copy_helper "layout"
48
+ end
49
+
50
+ def add_user
51
+ copy_migration "20140502222428_create_users.rb"
52
+ copy_scaffold "users"
53
+ copy_scaffold "layouts"
54
+ copy_scaffold "friendships"
55
+ copy_views "sessions"
56
+ copy_controller "sessions_controller.rb"
57
+ copy_helper "apple"
58
+ copy_helper "controllers"
59
+ copy_helper "layout"
60
+ copy_helper "sessions"
61
+ add_user_authentication
62
+ add_user_routes
63
+ add_layouts_routes
64
+ end
65
+
66
+ def rake_notes
67
+ run "rake notes"
68
+ end
69
+
70
+ def run_git_for_the_first_time
71
+ run "git init"
72
+ end
73
+
74
+ private
75
+
76
+ def copy_controller(passpath)
77
+ copy_file "app/controllers/#{passpath}"
78
+ end
79
+
80
+ def copy_helper(pass_helper_name)
81
+ copy_file "app/helpers/#{pass_helper_name}_helper.rb"
82
+ add_helper_to_app pass_helper_name
83
+ end
84
+
85
+ def copy_migration(passpath)
86
+ copy_file "db/migrate/#{passpath}"
87
+ end
88
+
89
+ def copy_models(passpath)
90
+ copy_file "app/models/#{passpath}"
91
+ end
92
+
93
+ def copy_scaffold(passname)
94
+ copy_views passname
95
+ copy_helper passname
96
+ copy_controller "#{passname}_controller.rb"
97
+ copy_models "#{passname.singularize}.rb"
98
+ end
99
+
100
+ def copy_views(passpath)
101
+ directory "app/views/#{passpath}"
102
+ end
103
+
104
+ def add_helper_to_app(pass_helper_name)
105
+ pass_injection = " include #{pass_helper_name.camelcase}Helper\n"
106
+ pass_file = "app/controllers/application_controller.rb"
107
+ pass_after = "class ApplicationController < ActionController::Base\n"
108
+ inject_into_file pass_file, pass_injection, :after => pass_after
109
+ end
110
+
111
+ def adapt_file(passpath)
112
+ generator "copy", "foobar #{name} #{passpath}"
113
+ end
114
+
115
+ def add_user_authentication
116
+ copy_file "lib/controller_authentication.rb"
117
+
118
+ pass_path = "config/application.rb"
119
+ pass_target = " class Application < Rails::Application\n"
120
+ pass_injection = " config.autoload_paths << \"\#{config.root}/lib\"\n"
121
+ inject_into_file pass_path, pass_injection, :after => pass_target
122
+
123
+ pass_path = "app/controllers/application_controller.rb"
124
+ pass_target = "class ApplicationController < ActionController::Base\n"
125
+ pass_injection = " include ControllerAuthentication\n"
126
+ inject_into_file pass_path, pass_injection, :after => pass_target
127
+
128
+ end
129
+
130
+ def add_layouts_routes
131
+ inject_into_file "config/routes.rb", "
132
+ resources :layouts
133
+ get 'activity/:from_name/:from_id/:activity/:to_name(/:to_id)' => 'layouts#index', as: :activity
134
+ ", :before => "\n resources :users"
135
+ end
136
+
137
+ def add_user_routes
138
+ inject_into_file "config/routes.rb", "
139
+ resources :users
140
+ resources :sessions
141
+ root 'users#new'
142
+ match 'user/home' => 'users#show', :as => :user_home, via: [:get, :post]
143
+ get 'user/edit' => 'users#edit', :as => :edit_current_user
144
+ get 'signup' => 'users#new', :as => :signup
145
+ get 'logout' => 'sessions#destroy', :as => :logout
146
+ get 'login' => 'sessions#new', :as => :login
147
+ ", :after => "routes.draw do\n"
148
+ end
149
+
150
+
151
+ end
@@ -0,0 +1,44 @@
1
+ Description:
2
+
3
+ Explain the generator
4
+
5
+ Type: "success save"
6
+
7
+ 1. saves core, universal directories and files to a storage app called "success",
8
+ in a sibiling directory to the current app directory
9
+ (basically, if you are in /mycoolapp, the "success" is located at "../success").
10
+
11
+ Example:
12
+
13
+ rails generate success save
14
+
15
+ This will run:
16
+
17
+ Reference: http://rubydoc.info/github/wycats/thor/master/Thor/Actions
18
+
19
+ Where directory and add_file copy recursively files from current to "success" app in "../success" direcory
20
+
21
+ directory "app", "../success/app"
22
+ directory "config", "../success/config"
23
+ directory "lib", "../success/lib"
24
+ directory "public/themes", "../success/public/themes"
25
+ copy_file "config/initializers/fog.rb", "../success/config/initializers/fog.rb"
26
+ copy_file "config/application.yml", "../success/config/application.yml"
27
+ copy_file "public/favicon.ico", "../success/public/favicon.ico"
28
+ copy_file ".gitignore", "../success/.gitignore"
29
+ copy_file "Gemfile", "../success/Gemfile"
30
+
31
+
32
+ rails generate success fresh
33
+
34
+ Does the reverse of save
35
+
36
+ directory "../success/app/controllers/layouts_controller.rb", "app/controllers/layouts_controller.rb"
37
+ directory "../success/app/views/layouts", "app/views/layouts"
38
+ directory "../success/app/helpers/layouts_helper.rb", "app/helpers/layouts_helper.rb"
39
+ directory "../success/app/helpers/layout_helper.rb", "app/helpers/layout_helper.rb"
40
+ directory "../success/lib/generators", "lib/generators"
41
+ directory "../success/public/themes", "public/themes"
42
+ copy_file "../success/Gemfile", "Gemfile"
43
+
44
+
@@ -0,0 +1,18 @@
1
+ class SuccessGenerator < Rails::Generators::NamedBase
2
+
3
+ # Looks and starts here: "/"
4
+ source_root File.expand_path('../../../../', __FILE__)
5
+
6
+ def save_app
7
+ run "rails g copy #{name} foobar app ../success/app"
8
+ run "rails g copy #{name} foobar config ../success/config"
9
+ run "rails g copy #{name} foobar lib ../success/lib"
10
+ run "rails g copy #{name} foobar lib ../success/lib"
11
+ run "rails g copy #{name} foobar Gemfile ../success/Gemfile"
12
+ directory "public/themes", "../success/public/themes"
13
+ copy_file "config/initializers/fog.rb", "../success/config/initializers/fog.rb"
14
+ copy_file "public/favicon.ico", "../success/public/favicon.ico"
15
+ copy_file ".gitignore", "../success/.gitignore"
16
+ end
17
+
18
+ end
data/lib/tasks/.keep ADDED
File without changes
data/makena/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/makena/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in makena.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 makenabots
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/makena/README.md ADDED
@@ -0,0 +1,32 @@
1
+ # Makena
2
+
3
+ Makena gem adds Dave Makena's favorite methods for handling views, controllers, models, and generators for.
4
+
5
+ ## Installation
6
+
7
+ app/controllers/application_controller.rb
8
+ include LayoutsHelper
9
+
10
+ app/helpers/layouts_helper.rb
11
+ add this:
12
+ include Makena
13
+
14
+ And then execute:
15
+
16
+ $ bundle
17
+
18
+ Or install it yourself as:
19
+
20
+ $ gem install makena
21
+
22
+ ## Usage
23
+
24
+ TODO: Write usage
25
+
26
+ ## Contributing
27
+
28
+ 1. Fork it ( http://github.com/<my-github-username>/makena/fork )
29
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
30
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
31
+ 4. Push to the branch (`git push origin my-new-feature`)
32
+ 5. Create new Pull Request
data/makena/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,21 @@
1
+ require "makena/version"
2
+ require "makena/tree"
3
+ require "makena/models"
4
+ require "makena/views"
5
+ require "makena/layouts"
6
+ require "makena/controllers"
7
+ require "makena/image"
8
+ require "makena/gps"
9
+ require "pry"
10
+
11
+ module Makena
12
+
13
+ include Tree
14
+ include Models
15
+ include Views
16
+ include Layouts
17
+ include Controllers
18
+ include Image
19
+ include Gps
20
+
21
+ end
@@ -0,0 +1,218 @@
1
+ module Controllers
2
+
3
+ # standard index
4
+ def controller_index(pass_class, pass_params)
5
+ pass_sender = pass_class.to_s.underscore
6
+ @params = pass_params
7
+ pass_namer = makena(pass_sender, "sender").split("_").first
8
+ @objs = (logged_in? ? current_user.send(pass_sender.pluralize).order("#{pass_namer} ASC") : [])
9
+ #instance_variable_set("@#{pass_sender.pluralize}", (logged_in? ? current_user.send(pass_sender.pluralize).order("#{pass_namer} ASC") : []) )
10
+ end
11
+
12
+ #controller_create_user(user_params)
13
+ #=> *new user from user_params"
14
+ def controller_create_user(user_params, notice)
15
+ @user = User.new(user_params)
16
+ respond_to do |format|
17
+ if @user.save
18
+ session[:user_id] = @user.id
19
+ format.html { redirect_to @user, notice: notice }
20
+ else
21
+ format.html { render :new }
22
+ end
23
+ end
24
+ end
25
+
26
+ # standard create
27
+ def controller_create(pass_class, pass_params, pass_notice)
28
+ if pass_params["pass_params"].present?
29
+ @params = eval pass_params["pass_params"].to_s
30
+ pass_params.delete("pass_params")
31
+ else
32
+ @params = nil
33
+ end
34
+ pass_obj = pass_class.new(pass_params)
35
+ respond_to do |format|
36
+ if pass_obj.save
37
+ handle_specials(pass_obj)
38
+ pass_obj, pass_notice = controller_add(pass_obj) if @params.present?
39
+ format.html { redirect_to pass_obj, notice: pass_notice }
40
+ format.json { render :show, status: :created, location: pass_obj }
41
+ else
42
+ format.html { render :new }
43
+ format.json { render json: pass_obj.errors, status: :unprocessable_entity }
44
+ end
45
+ end
46
+ end
47
+
48
+ # standard update
49
+ def controller_update(pass_obj, pass_params, pass_notice)
50
+ respond_to do |format|
51
+ if pass_obj.update(pass_params)
52
+ handle_specials(pass_obj)
53
+ pass_obj.save
54
+ if pass_params["remove_image"]=="1"
55
+ begin; pass_obj.remove_image!; rescue; end
56
+ end
57
+ format.html { redirect_to pass_obj, notice: pass_notice }
58
+ format.json { render :show, status: :ok, location: pass_obj }
59
+ else
60
+ format.html { render :edit }
61
+ format.json { render json: pass_obj.errors, status: :unprocessable_entity }
62
+ end
63
+ end
64
+ end
65
+
66
+ # standard destroy
67
+ def controller_destroy(pass_obj, pass_redirect, pass_notice)
68
+ pass_obj.destroy
69
+ respond_to do |format|
70
+ format.html { redirect_to pass_redirect, notice: pass_notice }
71
+ format.json { head :no_content }
72
+ end
73
+ end
74
+
75
+ # A add B
76
+ # If passed and obj, then it is added to list of objects to add.
77
+ def controller_add(pass_obj=nil)
78
+
79
+ from_name = @params["from_name"]
80
+ from_id = @params["from_id"]
81
+ from_rel = @params["from_rel"]
82
+ activity = @params["activity"]
83
+ to_name = @params["to_name"]
84
+ to_rel = @params["to_rel"]
85
+
86
+ to_ids = params["subjects"].present? ? params["subjects"].keys.to_a : []
87
+ to_ids += [pass_obj.id.to_s] if (pass_obj.present? and !to_ids.include?(pass_obj.id.to_s))
88
+ for to_id in to_ids
89
+ sender, hsh = controller_sender_generate(pass_obj, from_name, from_id, from_rel, to_name, to_id, to_rel)
90
+ current_user.send(sender).find_or_create_by(hsh) if sender
91
+ end
92
+
93
+ if from_name=="user"
94
+ obj = User.find(from_id)
95
+ else
96
+ obj = current_user.send(from_name.pluralize).find(from_id)
97
+ end
98
+ notice = "#{activity.upcase} #{from_name.humanize} #{(to_rel||to_name).humanize} processed."
99
+ return [obj, notice]
100
+ end
101
+
102
+ # A add B
103
+ # If passed and obj, then it is added to list of objects to add.
104
+ def controller_copy(pass_obj=nil)
105
+ from_name = @params["from_name"]
106
+ from_id = @params["from_id"]
107
+ from_rel = @params["from_rel"]
108
+ activity = @params["activity"]
109
+ to_name = @params["to_name"]
110
+ to_rel = @params["to_rel"]
111
+ to_ids = params["subjects"].present? ? params["subjects"].keys.to_a : []
112
+ to_ids += [pass_obj.id.to_s] if (pass_obj.present? and !to_ids.include?(pass_obj.id.to_s))
113
+ for to_id in to_ids
114
+ sender, hsh = controller_sender_generate(pass_obj, from_name, from_id, from_rel, to_name, to_id, to_rel)
115
+ from_obj = from_name.singularize=="user" ? current_user : current_user.send(from_name.pluralize).find(from_id)
116
+ to_obj = current_user.send(to_name.pluralize).find(to_id)
117
+ obj = to_obj.dup
118
+ obj.save
119
+ from_obj.send(sender).create(hsh) if sender
120
+ end
121
+ notice = "#{activity.upcase} #{from_name.humanize} #{(to_rel||to_name).humanize} processed."
122
+ return [obj, notice]
123
+ end
124
+
125
+ # A remove B
126
+ def controller_remove(pass_obj=nil)
127
+ from_name = @params["from_name"]
128
+ from_id = @params["from_id"]
129
+ from_rel = @params["from_rel"]
130
+ activity = @params["activity"]
131
+ to_name = @params["to_name"]
132
+ to_rel = @params["to_rel"]
133
+ to_ids = params["subjects"].present? ? params["subjects"].keys.to_a : []
134
+ to_ids += [pass_obj.id.to_s] if (pass_obj.present? and !to_ids.include?(pass_obj.id.to_s))
135
+ for to_id in to_ids
136
+ sender, hsh = controller_sender_generate(pass_obj, from_name, from_id, from_rel, to_name, to_id, to_rel)
137
+ if sender
138
+ for destroyable in current_user.send(sender).where(hsh)
139
+ destroyable.destroy
140
+ end
141
+ end
142
+ end
143
+ if from_name=="user"
144
+ obj = User.find(from_id)
145
+ else
146
+ obj = current_user.send(from_name.pluralize).find(from_id)
147
+ end
148
+ notice = "#{activity.upcase} #{from_name.humanize} #{(to_rel||to_name).humanize} processed."
149
+ return [obj, notice]
150
+ end
151
+
152
+ # A destroy B
153
+ def controller_destroy(pass_obj=nil)
154
+ from_name = @params["from_name"]
155
+ from_id = @params["from_id"]
156
+ from_rel = @params["from_rel"]
157
+ activity = @params["activity"]
158
+ to_name = @params["to_name"]
159
+ to_rel = @params["to_rel"]
160
+ to_ids = params["subjects"].present? ?
161
+ (params["subjects"].keys - [from_id.to_s]) :
162
+ (pass_obj.present? ? ([pass_obj.id.to_s] - [from_id.to_s]) : [])
163
+ for to_id in to_ids
164
+ for destroyable in current_user.send(to_name.pluralize).where(id: to_ids)
165
+ destroyable.destroy
166
+ end
167
+ end
168
+ if from_name=="user"
169
+ obj = User.find(from_id)
170
+ else
171
+ obj = current_user.send(from_name.pluralize).find(from_id)
172
+ end
173
+ notice = "#{activity.upcase} #{from_name.humanize} #{(to_rel||to_name).humanize} processed."
174
+ return [obj, notice]
175
+ end
176
+
177
+ protected
178
+
179
+ # @user.address = "123 Street"
180
+ # handle_specials(@user)
181
+ #=> @user.content = "<h1>Foobar</h1>"
182
+ # @user.address = nil
183
+ # handle_specials(@user)
184
+ #=> @user.name = "Foobar"
185
+ def handle_specials(pass_obj)
186
+ if makena(pass_obj, :specials).include?(:name_by_content_by_address)
187
+ pass_content = pass_obj.content.to_s.strip.present? ? pass_obj.content.to_s.strip : nil
188
+ pass_address = pass_obj.address.to_s.strip.present? ? pass_obj.address.to_s.strip : nil
189
+ pass_coords = (pass_obj.latitude and pass_obj.longitude) ? "#{pass_obj.latitude.to_s}/#{pass_obj.longitude.to_s}" : nil
190
+ pass_obj.name=(pass_content||pass_address||pass_coords||Time.now).to_s.truncate(245)
191
+ elsif makena(pass_obj, :specials).include?(:name_by_content)
192
+ pass_content = pass_obj.content.to_s.strip.present? ? pass_obj.content.to_s.strip : nil
193
+ pass_obj.name=(pass_content||Time.now).to_s.truncate(245)
194
+ end
195
+ pass_obj.save
196
+ return pass_obj
197
+ end
198
+
199
+ # controller_sender_generate(pass_obj, from_name, from_id, to_name, to_id)
200
+ def controller_sender_generate(pass_obj, from_name, from_id, from_rel, to_name, to_id, to_rel)
201
+ hsh={}
202
+ if from_name==to_name
203
+ hsh["#{from_rel}_id".to_sym]=from_id.to_i
204
+ hsh["#{to_rel}_id".to_sym]=to_id.to_i
205
+ else
206
+ hsh["#{from_name.singularize}_id".to_sym]=from_id.to_i
207
+ hsh["#{to_name.singularize}_id".to_sym]=to_id.to_i
208
+ end
209
+ if makena_classes_connecting_u.include?(sender="#{from_name.singularize}_#{to_name.pluralize}")
210
+ elsif makena_classes_connecting_u.include?(sender="#{to_name.singularize}_#{from_name.pluralize}")
211
+ else
212
+ sender = nil
213
+ end
214
+ [sender, hsh]
215
+ end
216
+
217
+ end
218
+