hobo 1.1.0 → 1.3.0.RC

Sign up to get free protection for your applications and to get access to all the features.
Files changed (278) hide show
  1. data/CHANGES.txt +238 -287
  2. data/Rakefile +14 -31
  3. data/VERSION +1 -0
  4. data/{lib/hobo → app/controllers}/dev_controller.rb +6 -6
  5. data/app/controllers/dryml_support_controller.rb +13 -0
  6. data/{rails_generators/hobo_front_controller/templates → app/views/dev}/summary.dryml +7 -10
  7. data/bin/hobo +12 -144
  8. data/config/initializers/inflections.rb +3 -0
  9. data/config/routes.rb +6 -0
  10. data/{doctest → doctests}/hobo/lifecycles.rdoctest +40 -59
  11. data/{doctest → doctests/hobo}/model.rdoctest +33 -40
  12. data/{doctest → doctests/hobo}/multi_model_forms.rdoctest +15 -19
  13. data/{doctest → doctests/hobo}/scopes.rdoctest +27 -41
  14. data/doctests/prepare_testapp.rb +8 -0
  15. data/hobo.gemspec +26 -199
  16. data/lib/generators/hobo/activation_email.rb +11 -0
  17. data/lib/generators/hobo/admin_subsite/admin_subsite_generator.rb +35 -0
  18. data/lib/generators/hobo/admin_subsite/templates/admin.css +20 -0
  19. data/lib/generators/hobo/admin_subsite/templates/admin_tag_injection.erb +10 -0
  20. data/{rails_generators/hobo_admin_site → lib/generators/hobo/admin_subsite}/templates/application.dryml +0 -0
  21. data/{rails_generators/hobo_admin_site/templates/controller.rb → lib/generators/hobo/admin_subsite/templates/controller.rb.erb} +5 -5
  22. data/lib/generators/hobo/admin_subsite/templates/users_index.dryml +7 -0
  23. data/lib/generators/hobo/assets/assets_generator.rb +18 -0
  24. data/{rails_generators/hobo → lib/generators/hobo/assets}/templates/application.css +0 -0
  25. data/lib/generators/hobo/assets/templates/application.dryml.erb +9 -0
  26. data/{rails_generators/hobo → lib/generators/hobo/assets}/templates/dryml-support.js +2 -2
  27. data/lib/generators/hobo/assets/templates/dryml_taglibs_initializer.rb +1 -0
  28. data/lib/generators/hobo/assets/templates/en_injection.yml +19 -0
  29. data/{rails_generators/hobo → lib/generators/hobo/assets}/templates/guest.rb +1 -1
  30. data/lib/generators/hobo/controller.rb +35 -0
  31. data/lib/generators/hobo/controller/controller_generator.rb +6 -0
  32. data/lib/generators/hobo/controller/templates/controller.rb.erb +7 -0
  33. data/{rails_generators/hobo_front_controller → lib/generators/hobo/front_controller}/USAGE +0 -0
  34. data/lib/generators/hobo/front_controller/front_controller_generator.rb +55 -0
  35. data/{rails_generators/hobo_front_controller/templates/controller.rb → lib/generators/hobo/front_controller/templates/controller.rb.erb} +0 -0
  36. data/{rails_generators/hobo_front_controller → lib/generators/hobo/front_controller}/templates/index.dryml +6 -12
  37. data/lib/generators/hobo/i18n/i18n_generator.rb +35 -0
  38. data/lib/generators/hobo/i18n/templates/app.de.yml +30 -0
  39. data/lib/generators/hobo/i18n/templates/app.en.yml +25 -0
  40. data/lib/generators/hobo/i18n/templates/app.es.yml +31 -0
  41. data/lib/generators/hobo/i18n/templates/app.fr.yml +26 -0
  42. data/lib/generators/hobo/i18n/templates/app.it.yml +28 -0
  43. data/lib/generators/hobo/i18n/templates/app.pt-PT.yml +25 -0
  44. data/lib/generators/hobo/i18n/templates/app.ru.yml +24 -0
  45. data/lib/generators/hobo/i18n/templates/hobo.de.yml +204 -0
  46. data/lib/generators/hobo/i18n/templates/hobo.en.yml +195 -0
  47. data/lib/generators/hobo/i18n/templates/hobo.es.yml +202 -0
  48. data/lib/generators/hobo/i18n/templates/hobo.fr.yml +195 -0
  49. data/lib/generators/hobo/i18n/templates/hobo.it.yml +202 -0
  50. data/lib/generators/hobo/i18n/templates/hobo.pt-PT.yml +196 -0
  51. data/lib/generators/hobo/i18n/templates/hobo.ru.yml +200 -0
  52. data/lib/generators/hobo/invite_only.rb +18 -0
  53. data/lib/generators/hobo/model/USAGE +19 -0
  54. data/lib/generators/hobo/model/model_generator.rb +11 -0
  55. data/{rails_generators/hobo_model/templates/model.rb → lib/generators/hobo/model/templates/model_injection.rb.erb} +0 -2
  56. data/{rails_generators/hobo_rapid → lib/generators/hobo/rapid}/USAGE +0 -0
  57. data/lib/generators/hobo/rapid/rapid_generator.rb +24 -0
  58. data/{rails_generators/hobo_rapid → lib/generators/hobo/rapid}/templates/IE7.js +0 -0
  59. data/{rails_generators/hobo_rapid → lib/generators/hobo/rapid}/templates/blank.gif +0 -0
  60. data/{rails_generators/hobo_rapid → lib/generators/hobo/rapid}/templates/hobo-rapid.css +0 -0
  61. data/{rails_generators/hobo_rapid → lib/generators/hobo/rapid}/templates/hobo-rapid.js +65 -65
  62. data/{rails_generators/hobo_rapid → lib/generators/hobo/rapid}/templates/ie7-recalc.js +21 -21
  63. data/{rails_generators/hobo_rapid → lib/generators/hobo/rapid}/templates/lowpro.js +31 -31
  64. data/{rails_generators/hobo_rapid → lib/generators/hobo/rapid}/templates/reset.css +1 -1
  65. data/lib/generators/hobo/rapid/templates/themes/clean-sidemenu/public/images/100-ACD3E6-DBE1E5-H.png +0 -0
  66. data/lib/generators/hobo/rapid/templates/themes/clean-sidemenu/public/images/100-DBE1E5-FCFEF5-H.png +0 -0
  67. data/lib/generators/hobo/rapid/templates/themes/clean-sidemenu/public/images/300-3B5F87-ACD3E6-H.png +0 -0
  68. data/{rails_generators/hobo_rapid/templates/themes/clean → lib/generators/hobo/rapid/templates/themes/clean-sidemenu}/public/images/spinner.gif +0 -0
  69. data/lib/generators/hobo/rapid/templates/themes/clean-sidemenu/public/stylesheets/clean-sidemenu.css +81 -0
  70. data/lib/generators/hobo/rapid/templates/themes/clean-sidemenu/views/clean-sidemenu.dryml +30 -0
  71. data/{rails_generators/hobo_rapid → lib/generators/hobo/rapid}/templates/themes/clean/public/images/101-3B5F87-ACD3E6.png +0 -0
  72. data/{rails_generators/hobo_rapid → lib/generators/hobo/rapid}/templates/themes/clean/public/images/30-3E547A-242E42.png +0 -0
  73. data/{rails_generators/hobo_rapid → lib/generators/hobo/rapid}/templates/themes/clean/public/images/30-DBE1E5-FCFEF5.png +0 -0
  74. data/{rails_generators/hobo_rapid → lib/generators/hobo/rapid}/templates/themes/clean/public/images/300-ACD3E6-fff.png +0 -0
  75. data/{rails_generators/hobo_rapid → lib/generators/hobo/rapid}/templates/themes/clean/public/images/50-ACD3E6-fff.png +0 -0
  76. data/{rails_generators/hobo_rapid → lib/generators/hobo/rapid}/templates/themes/clean/public/images/fieldbg.gif +0 -0
  77. data/{rails_generators/hobo_rapid → lib/generators/hobo/rapid}/templates/themes/clean/public/images/pencil.png +0 -0
  78. data/{rails_generators/hobo_rapid → lib/generators/hobo/rapid}/templates/themes/clean/public/images/small_close.png +0 -0
  79. data/lib/generators/hobo/rapid/templates/themes/clean/public/images/spinner.gif +0 -0
  80. data/{rails_generators/hobo_rapid → lib/generators/hobo/rapid}/templates/themes/clean/public/stylesheets/clean.css +16 -16
  81. data/{rails_generators/hobo_rapid → lib/generators/hobo/rapid}/templates/themes/clean/public/stylesheets/rapid-ui.css +3 -3
  82. data/{rails_generators/hobo_rapid → lib/generators/hobo/rapid}/templates/themes/clean/views/clean.dryml +1 -1
  83. data/lib/generators/hobo/resource/resource_generator.rb +23 -0
  84. data/lib/generators/hobo/routes/USAGE +9 -0
  85. data/lib/generators/hobo/routes/router.rb +115 -0
  86. data/lib/generators/hobo/routes/routes_generator.rb +40 -0
  87. data/lib/generators/hobo/routes/templates/hobo_routes.rb.erb +33 -0
  88. data/lib/generators/hobo/setup_wizard/USAGE +4 -0
  89. data/lib/generators/hobo/setup_wizard/setup_wizard_generator.rb +274 -0
  90. data/lib/generators/hobo/subsite.rb +48 -0
  91. data/lib/generators/hobo/subsite/subsite_generator.rb +16 -0
  92. data/{rails_generators/hobo_subsite → lib/generators/hobo/subsite}/templates/application.dryml +0 -0
  93. data/{rails_generators/hobo_subsite/templates/controller.rb → lib/generators/hobo/subsite/templates/controller.rb.erb} +1 -1
  94. data/lib/generators/hobo/subsite_taglib/subsite_taglib_generator.rb +16 -0
  95. data/{rails_generators/hobo_admin_site/templates/site_taglib.dryml → lib/generators/hobo/subsite_taglib/templates/taglib.dryml.erb} +9 -10
  96. data/lib/generators/hobo/taglib.rb +12 -0
  97. data/lib/generators/hobo/test_framework/test_framework_generator.rb +72 -0
  98. data/lib/generators/hobo/test_options.rb +19 -0
  99. data/{rails_generators/hobo_user_controller → lib/generators/hobo/user_controller}/templates/accept_invitation.dryml +0 -0
  100. data/lib/generators/hobo/user_controller/templates/controller.rb.erb +31 -0
  101. data/lib/generators/hobo/user_controller/user_controller_generator.rb +25 -0
  102. data/lib/generators/hobo/user_mailer/templates/activation.erb +9 -0
  103. data/{rails_generators/hobo_user_model → lib/generators/hobo/user_mailer}/templates/forgot_password.erb +2 -2
  104. data/{rails_generators/hobo_user_model → lib/generators/hobo/user_mailer}/templates/invite.erb +2 -2
  105. data/lib/generators/hobo/user_mailer/templates/mailer.rb.erb +25 -0
  106. data/lib/generators/hobo/user_mailer/user_mailer_generator.rb +33 -0
  107. data/lib/generators/hobo/user_model/USAGE +12 -0
  108. data/{rails_generators/hobo_user_model/templates/model.rb → lib/generators/hobo/user_model/templates/model_injection.rb.erb} +40 -20
  109. data/lib/generators/hobo/user_model/user_model_generator.rb +23 -0
  110. data/lib/generators/hobo/user_resource/user_resource_generator.rb +27 -0
  111. data/lib/hobo.rb +29 -129
  112. data/lib/hobo/controller.rb +37 -47
  113. data/lib/hobo/controller/authentication_support.rb +109 -0
  114. data/lib/hobo/{model_controller.rb → controller/model.rb} +71 -79
  115. data/lib/hobo/{user_controller.rb → controller/user.rb} +59 -49
  116. data/lib/hobo/engine.rb +80 -0
  117. data/lib/hobo/extensions/action_controller/hobo_methods.rb +44 -0
  118. data/lib/hobo/extensions/action_mailer/helper.rb +38 -0
  119. data/lib/{action_view_extensions/helpers → hobo/extensions/action_view}/tag_helper.rb +5 -2
  120. data/lib/hobo/extensions/action_view/translation_helper.rb +25 -0
  121. data/lib/hobo/extensions/active_model/name.rb +16 -0
  122. data/lib/hobo/extensions/active_model/translation.rb +35 -0
  123. data/lib/{active_record/association_collection.rb → hobo/extensions/active_record/associations/collection.rb} +8 -17
  124. data/lib/{active_record/association_proxy.rb → hobo/extensions/active_record/associations/proxy.rb} +6 -7
  125. data/lib/hobo/extensions/active_record/associations/reflection.rb +23 -0
  126. data/lib/hobo/extensions/active_record/associations/scope.rb +35 -0
  127. data/lib/hobo/extensions/active_record/hobo_methods.rb +11 -0
  128. data/lib/hobo/extensions/active_record/permissions.rb +159 -0
  129. data/lib/hobo/extensions/active_record/relation_with_origin.rb +28 -0
  130. data/lib/hobo/extensions/array.rb +27 -0
  131. data/lib/hobo/extensions/enumerable.rb +12 -0
  132. data/lib/hobo/extensions/i18n.rb +17 -0
  133. data/lib/hobo/{hobo_helper.rb → helper.rb} +58 -31
  134. data/lib/hobo/helper/translations.rb +54 -0
  135. data/lib/hobo/helper/translations/normalizer.rb +39 -0
  136. data/lib/hobo/model.rb +61 -95
  137. data/lib/hobo/model/accessible_associations.rb +178 -0
  138. data/lib/hobo/{find_for.rb → model/find_for.rb} +17 -17
  139. data/lib/hobo/model/guest.rb +25 -0
  140. data/lib/hobo/model/include_in_save.rb +55 -0
  141. data/lib/hobo/model/lifecycles.rb +119 -0
  142. data/lib/hobo/model/lifecycles/actions.rb +146 -0
  143. data/lib/hobo/model/lifecycles/creator.rb +74 -0
  144. data/lib/hobo/model/lifecycles/lifecycle.rb +243 -0
  145. data/lib/hobo/model/lifecycles/state.rb +22 -0
  146. data/lib/hobo/model/lifecycles/transition.rb +70 -0
  147. data/lib/hobo/model/permissions.rb +448 -0
  148. data/lib/hobo/model/scopes.rb +38 -0
  149. data/lib/hobo/model/scopes/apply_scopes.rb +21 -0
  150. data/lib/hobo/model/scopes/automatic_scopes.rb +428 -0
  151. data/lib/hobo/model/user_base.rb +184 -0
  152. data/lib/hobo/model/view_hints.rb +123 -0
  153. data/{rapid_generators → lib/hobo/rapid/generators}/rapid/cards.dryml.erb +2 -2
  154. data/{rapid_generators → lib/hobo/rapid/generators}/rapid/forms.dryml.erb +3 -3
  155. data/{rapid_generators → lib/hobo/rapid/generators}/rapid/pages.dryml.erb +38 -51
  156. data/lib/hobo/rapid/helper.rb +166 -0
  157. data/{taglibs → lib/hobo/rapid/taglibs}/rapid.dryml +6 -5
  158. data/{taglibs → lib/hobo/rapid/taglibs}/rapid_core.dryml +286 -118
  159. data/{taglibs → lib/hobo/rapid/taglibs}/rapid_document_tags.dryml +2 -2
  160. data/{taglibs → lib/hobo/rapid/taglibs}/rapid_editing.dryml +45 -45
  161. data/{taglibs → lib/hobo/rapid/taglibs}/rapid_forms.dryml +190 -158
  162. data/{taglibs → lib/hobo/rapid/taglibs}/rapid_generics.dryml +12 -9
  163. data/lib/hobo/rapid/taglibs/rapid_i18n.dryml +107 -0
  164. data/{taglibs → lib/hobo/rapid/taglibs}/rapid_lifecycles.dryml +7 -7
  165. data/{taglibs → lib/hobo/rapid/taglibs}/rapid_navigation.dryml +15 -15
  166. data/{taglibs → lib/hobo/rapid/taglibs}/rapid_pages.dryml +37 -36
  167. data/{taglibs → lib/hobo/rapid/taglibs}/rapid_plus.dryml +107 -43
  168. data/{taglibs → lib/hobo/rapid/taglibs}/rapid_summary.dryml +28 -57
  169. data/{taglibs → lib/hobo/rapid/taglibs}/rapid_support.dryml +9 -9
  170. data/{taglibs → lib/hobo/rapid/taglibs}/rapid_user_pages.dryml +41 -40
  171. data/lib/hobo/routes.rb +31 -0
  172. data/{doctest → test/doctest}/hobo/hobo_helper.rdoctest +11 -11
  173. data/test/irt/generators/admin_subsite.irt +27 -0
  174. data/test/irt/generators/assets.irt +16 -0
  175. data/test/irt/generators/controller.irt +6 -0
  176. data/test/irt/generators/front_controller.irt +30 -0
  177. data/test/irt/generators/helper.rb +31 -0
  178. data/test/irt/generators/model.irt +28 -0
  179. data/test/irt/generators/partials/_account_user_model_tests.rb +21 -0
  180. data/test/irt/generators/partials/_accounts_users_controller_tests.rb +15 -0
  181. data/test/irt/generators/partials/_default_user_model_tests.rb +21 -0
  182. data/test/irt/generators/partials/_default_users_controller_tests.rb +16 -0
  183. data/test/irt/generators/partials/_house_controller_tests.rb +15 -0
  184. data/test/irt/generators/partials/_house_model_tests.rb +18 -0
  185. data/test/irt/generators/partials/_subsite_taglib_admin.rb +4 -0
  186. data/test/irt/generators/partials/_subsite_taglib_admin_invite_only.rb +3 -0
  187. data/test/irt/generators/partials/_subsite_taglib_noopt.rb +4 -0
  188. data/test/irt/generators/partials/_subsite_taglib_variables.rb +27 -0
  189. data/test/irt/generators/partials/_user_mailer_tests.rb +19 -0
  190. data/test/irt/generators/rapid.irt +29 -0
  191. data/test/irt/generators/resource.irt +8 -0
  192. data/test/irt/generators/subsite.irt +52 -0
  193. data/test/irt/generators/subsite_taglib.irt +23 -0
  194. data/test/irt/generators/test_framework.irt +62 -0
  195. data/test/irt/generators/user_controller.irt +10 -0
  196. data/test/irt/generators/user_mailer.irt +20 -0
  197. data/test/irt/generators/user_model.irt +10 -0
  198. data/test/irt/generators/user_resource.irt +14 -0
  199. data/test/irt/readme.txt +7 -0
  200. data/test/permissions/models/models.rb +27 -24
  201. data/test/permissions/test_permissions.rb +104 -104
  202. metadata +239 -217
  203. data/lib/active_record/association_reflection.rb +0 -20
  204. data/lib/active_record/viewhints_validations_interceptor.rb +0 -9
  205. data/lib/hobo/accessible_associations.rb +0 -183
  206. data/lib/hobo/authentication_support.rb +0 -131
  207. data/lib/hobo/generator.rb +0 -26
  208. data/lib/hobo/guest.rb +0 -25
  209. data/lib/hobo/include_in_save.rb +0 -55
  210. data/lib/hobo/lifecycles.rb +0 -137
  211. data/lib/hobo/lifecycles/actions.rb +0 -142
  212. data/lib/hobo/lifecycles/creator.rb +0 -72
  213. data/lib/hobo/lifecycles/lifecycle.rb +0 -249
  214. data/lib/hobo/lifecycles/state.rb +0 -22
  215. data/lib/hobo/lifecycles/transition.rb +0 -70
  216. data/lib/hobo/model_router.rb +0 -290
  217. data/lib/hobo/permissions.rb +0 -451
  218. data/lib/hobo/permissions/associations.rb +0 -175
  219. data/lib/hobo/rapid_helper.rb +0 -157
  220. data/lib/hobo/scopes.rb +0 -43
  221. data/lib/hobo/scopes/apply_scopes.rb +0 -23
  222. data/lib/hobo/scopes/association_proxy_extensions.rb +0 -62
  223. data/lib/hobo/scopes/automatic_scopes.rb +0 -421
  224. data/lib/hobo/scopes/named_scope_extensions.rb +0 -39
  225. data/lib/hobo/tasks/rails.rb +0 -4
  226. data/lib/hobo/translations.rb +0 -93
  227. data/lib/hobo/undefined_access_error.rb +0 -5
  228. data/lib/hobo/user.rb +0 -182
  229. data/lib/hobo/view_hints.rb +0 -115
  230. data/rails/init.rb +0 -10
  231. data/rails_generators/hobo/USAGE +0 -4
  232. data/rails_generators/hobo/hobo_generator.rb +0 -53
  233. data/rails_generators/hobo/templates/application.dryml +0 -1
  234. data/rails_generators/hobo/templates/initializer.rb +0 -2
  235. data/rails_generators/hobo_admin_site/USAGE +0 -16
  236. data/rails_generators/hobo_admin_site/hobo_admin_site_generator.rb +0 -45
  237. data/rails_generators/hobo_admin_site/templates/admin.css +0 -2
  238. data/rails_generators/hobo_admin_site/templates/users_index.dryml +0 -5
  239. data/rails_generators/hobo_front_controller/hobo_front_controller_generator.rb +0 -95
  240. data/rails_generators/hobo_front_controller/templates/functional_test.rb +0 -8
  241. data/rails_generators/hobo_front_controller/templates/helper.rb +0 -2
  242. data/rails_generators/hobo_model/USAGE +0 -25
  243. data/rails_generators/hobo_model/hobo_model_generator.rb +0 -43
  244. data/rails_generators/hobo_model/templates/fixtures.yml +0 -6
  245. data/rails_generators/hobo_model/templates/hints.rb +0 -7
  246. data/rails_generators/hobo_model/templates/unit_test.rb +0 -8
  247. data/rails_generators/hobo_model_controller/USAGE +0 -30
  248. data/rails_generators/hobo_model_controller/hobo_model_controller_generator.rb +0 -46
  249. data/rails_generators/hobo_model_controller/templates/controller.rb +0 -7
  250. data/rails_generators/hobo_model_controller/templates/functional_test.rb +0 -8
  251. data/rails_generators/hobo_model_controller/templates/helper.rb +0 -2
  252. data/rails_generators/hobo_model_resource/USAGE +0 -38
  253. data/rails_generators/hobo_model_resource/hobo_model_resource_generator.rb +0 -73
  254. data/rails_generators/hobo_model_resource/templates/controller.rb +0 -7
  255. data/rails_generators/hobo_model_resource/templates/functional_test.rb +0 -8
  256. data/rails_generators/hobo_model_resource/templates/helper.rb +0 -2
  257. data/rails_generators/hobo_rapid/hobo_rapid_generator.rb +0 -94
  258. data/rails_generators/hobo_subsite/USAGE +0 -16
  259. data/rails_generators/hobo_subsite/hobo_subsite_generator.rb +0 -73
  260. data/rails_generators/hobo_subsite/templates/site_taglib.dryml +0 -13
  261. data/rails_generators/hobo_user_controller/USAGE +0 -34
  262. data/rails_generators/hobo_user_controller/hobo_user_controller_generator.rb +0 -65
  263. data/rails_generators/hobo_user_controller/templates/controller.rb +0 -29
  264. data/rails_generators/hobo_user_controller/templates/functional_test.rb +0 -8
  265. data/rails_generators/hobo_user_controller/templates/helper.rb +0 -2
  266. data/rails_generators/hobo_user_model/USAGE +0 -16
  267. data/rails_generators/hobo_user_model/hobo_user_model_generator.rb +0 -46
  268. data/rails_generators/hobo_user_model/templates/fixtures.yml +0 -19
  269. data/rails_generators/hobo_user_model/templates/mailer.rb +0 -29
  270. data/rails_generators/hobo_user_model/templates/unit_test.rb +0 -8
  271. data/script/destroy +0 -14
  272. data/script/generate +0 -14
  273. data/taglibs/rapid_translations.dryml +0 -36
  274. data/tasks/environments.rake +0 -19
  275. data/tasks/hobo_tasks.rake +0 -58
  276. data/test/generators/test_generator_helper.rb +0 -29
  277. data/test/generators/test_helper.rb +0 -1
  278. data/test/generators/test_hobo_model_controller_generator.rb +0 -56
@@ -0,0 +1,28 @@
1
+ module ActiveRecord
2
+
3
+ class Relation
4
+ attr_accessor :origin, :origin_attribute
5
+ end
6
+
7
+ module Associations
8
+ class AssociationCollection
9
+
10
+ def scoped_with_origin
11
+ relation = scoped_without_origin.clone
12
+ relation.origin = @owner
13
+ relation.origin_attribute = @reflection.name
14
+ relation
15
+ end
16
+ alias_method_chain :scoped, :origin
17
+
18
+ def method_missing_with_origin(method, *args, &block)
19
+ res = method_missing_without_origin(method, *args, &block)
20
+ res.origin = @owner if res.respond_to?(:origin)
21
+ res.origin_attribute = @reflection.name if res.respond_to?(:origin_attribute)
22
+ res
23
+ end
24
+ alias_method_chain :method_missing, :origin
25
+
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,27 @@
1
+ # Add support for type metadata to arrays
2
+
3
+ require 'will_paginate/array'
4
+
5
+ class Array
6
+
7
+ attr_accessor :member_class, :origin, :origin_attribute
8
+
9
+ def to_url_path
10
+ base_path = origin.try.to_url_path
11
+ "#{base_path}/#{origin_attribute}" unless base_path.blank?
12
+ end
13
+
14
+ def typed_id
15
+ origin and origin_id = origin.try.typed_id and "#{origin_id}:#{origin_attribute}"
16
+ end
17
+
18
+ def paginate_with_hobo_metadata(*args, &block)
19
+ collection = paginate_without_hobo_metadata(*args, &block)
20
+ collection.member_class = member_class
21
+ collection.origin = try.proxy_owner
22
+ collection.origin_attribute = try.proxy_reflection._?.name
23
+ collection
24
+ end
25
+ alias_method_chain :paginate, :hobo_metadata
26
+
27
+ end
@@ -0,0 +1,12 @@
1
+ module Enumerable
2
+ def group_by_with_metadata(&block)
3
+ r=group_by_without_metadata(&block)
4
+ r.each do |k,v|
5
+ v.origin = origin
6
+ v.origin_attribute = origin_attribute
7
+ v.member_class = member_class
8
+ end
9
+ r
10
+ end
11
+ alias_method_chain :group_by, :metadata
12
+ end
@@ -0,0 +1,17 @@
1
+ I18n.module_eval do
2
+ class << self
3
+
4
+ def translate_with_show_keys(key, options = {})
5
+ translation = translate_without_show_keys(key, options)
6
+ return translation unless translation.is_a?(String)
7
+ keys = normalize_keys(locale, key, options[:scope]).join('.')
8
+ "[#{keys}]" + translation
9
+ end
10
+ alias_method_chain :translate, :show_keys
11
+
12
+ alias_method :t_without_show_keys, :t
13
+ alias_method :t, :translate_with_show_keys
14
+
15
+ end
16
+ end
17
+
@@ -1,6 +1,6 @@
1
1
  module Hobo
2
2
 
3
- module HoboHelper
3
+ module Helper
4
4
 
5
5
  def self.add_to_controller(controller)
6
6
  controller.send(:include, self)
@@ -31,7 +31,7 @@ module Hobo
31
31
 
32
32
 
33
33
  def base_url
34
- ActionController::Base.relative_url_root || ""
34
+ "#{Rails.application.config.action_controller.relative_url_root}"
35
35
  end
36
36
 
37
37
 
@@ -58,9 +58,9 @@ module Hobo
58
58
  options[:subsite] ||= self.subsite
59
59
  subsite, method = options.get :subsite, :method
60
60
 
61
- if obj.respond_to?(:member_class) && obj.respond_to?(:origin)
61
+ if obj.respond_to?(:member_class) && obj.respond_to?(:origin) && obj.origin
62
62
  # Asking for URL of a collection, e.g. category/1/adverts or category/1/adverts/new
63
-
63
+
64
64
  refl = obj.origin.class.reverse_reflection(obj.origin_attribute)
65
65
  owner_name = refl.name.to_s
66
66
  owner_name = owner_name.singularize if refl.macro == :has_many
@@ -89,7 +89,7 @@ module Hobo
89
89
  # Asking for url to post new record to
90
90
  obj = obj.class
91
91
  end
92
-
92
+
93
93
  klass = if obj.is_a?(Class)
94
94
  obj
95
95
  elsif obj.respond_to?(:member_class)
@@ -99,7 +99,7 @@ module Hobo
99
99
  end
100
100
  end
101
101
 
102
- if Hobo::ModelRouter.linkable?(klass, action, options)
102
+ if Hobo::Routes.linkable?(klass, action, options)
103
103
 
104
104
  url = base_url_for(obj, subsite, action)
105
105
  url += "/#{action_path || action}" unless action.in?(IMPLICIT_ACTIONS)
@@ -110,12 +110,34 @@ module Hobo
110
110
  end
111
111
 
112
112
 
113
+ def app_name(add_subsite=true)
114
+ an = Rails.application.config.hobo.app_name
115
+ if add_subsite && subsite
116
+ subsite_name = t 'hobo.admin.subsite_name', :default => subsite.titleize
117
+ an = an + " - #{subsite_name}"
118
+ end
119
+ an
120
+ end
121
+
122
+
113
123
  def base_url_for(object, subsite, action)
114
- path = object.to_url_path or HoboError.new("cannot create url for #{object.inspect} (#{object.class})")
124
+ path = object.to_url_path or Hobo::Error.new("cannot create url for #{object.inspect} (#{object.class})")
115
125
  "#{base_url}#{'/' + subsite unless subsite.blank?}/#{path}"
116
126
  end
117
127
 
118
128
 
129
+ def recognize_page_path
130
+ Rails.application.routes.recognize_path(params[:page_path]||request.fullpath)
131
+ end
132
+
133
+ def url_for_page_path(options={})
134
+ url_for recognize_page_path.merge(options)
135
+ end
136
+
137
+ def controller_action_from_page_path
138
+ recognize_page_path.values_at(:controller,:action)
139
+ end
140
+
119
141
  def _as_params(name, obj)
120
142
  if obj.is_a? Array
121
143
  obj.map {|x| _as_params("#{name}[]", x)}.join("&")
@@ -183,7 +205,7 @@ module Hobo
183
205
  [this, nil]
184
206
  elsif this_parent && this_field
185
207
  [this_parent, this_field]
186
- else
208
+ else
187
209
  [this, nil]
188
210
  end
189
211
  elsif args.length == 2
@@ -198,14 +220,14 @@ module Hobo
198
220
 
199
221
  object.editable_by?(current_user, field)
200
222
  end
201
-
223
+
202
224
 
203
225
  def can_delete?(object=this)
204
226
  object.destroyable_by?(current_user)
205
227
  end
206
228
 
207
229
 
208
-
230
+
209
231
  def can_call?(*args)
210
232
  method = args.last
211
233
  object = args.length == 2 ? args.first : this
@@ -213,7 +235,7 @@ module Hobo
213
235
  object.method_callable_by?(current_user, method)
214
236
  end
215
237
 
216
-
238
+
217
239
  # can_view? has special behaviour if it's passed a class or an
218
240
  # association-proxy -- it instantiates the class, or creates a new
219
241
  # instance "in" the association, and tests the permission of this
@@ -224,7 +246,7 @@ module Hobo
224
246
  # belongs_to the proxy owner.
225
247
  def can_view?(*args)
226
248
  # TODO: Man does this need a big cleanup!
227
-
249
+
228
250
  if args.empty?
229
251
  if this_parent && this_field
230
252
  object = this_parent
@@ -238,7 +260,7 @@ module Hobo
238
260
  else
239
261
  object, field = args
240
262
  end
241
-
263
+
242
264
  if field
243
265
  # Field can be a dot separated path
244
266
  if field.is_a?(String) && (path = field.split(".")).length > 1
@@ -248,7 +270,7 @@ module Hobo
248
270
  elsif (origin = object.try.origin)
249
271
  object, field = origin, object.origin_attribute
250
272
  end
251
-
273
+
252
274
  @can_view_cache ||= {}
253
275
  @can_view_cache[ [object, field] ] ||=
254
276
  if !object.respond_to?(:viewable_by?)
@@ -264,7 +286,7 @@ module Hobo
264
286
  false
265
287
  end
266
288
  end
267
-
289
+
268
290
 
269
291
  def select_viewable(collection=this)
270
292
  collection.select {|x| can_view?(x)}
@@ -321,19 +343,19 @@ module Hobo
321
343
 
322
344
 
323
345
  # Login url for a given user record or user class
324
- def forgot_password_url(user_class=Hobo::User.default_user_model)
346
+ def forgot_password_url(user_class=Hobo::Model::UserBase.default_user_model)
325
347
  send("#{user_class.name.underscore}_forgot_password_url") rescue nil
326
348
  end
327
349
 
328
350
 
329
351
  # Login url for a given user record or user class
330
- def login_url(user_class=Hobo::User.default_user_model)
352
+ def login_url(user_class=Hobo::Model::UserBase.default_user_model)
331
353
  send("#{user_class.name.underscore}_login_url") rescue nil
332
354
  end
333
355
 
334
356
 
335
357
  # Sign-up url for a given user record or user class
336
- def signup_url(user_class=Hobo::User.default_user_model)
358
+ def signup_url(user_class=Hobo::Model::UserBase.default_user_model)
337
359
  send("#{user_class.name.underscore}_signup_url") rescue nil
338
360
  end
339
361
 
@@ -352,12 +374,12 @@ module Hobo
352
374
 
353
375
 
354
376
  def current_page_url
355
- request.request_uri.match(/^([^?]*)/)._?[1]
377
+ request.fullpath.match(/^([^?]*)/)._?[1]
356
378
  end
357
379
 
358
380
  def query_params
359
- query = request.request_uri =~ /\?([^?]+)/ && $1
360
- result = HashWithIndifferentAccess.new
381
+ query = request.fullpath =~ /\?([^?]+)/ && $1
382
+ result = HashWithIndifferentAccess.new
361
383
  if query
362
384
  query.gsub!('+', ' ')
363
385
  query.split('&').each do |param|
@@ -373,6 +395,7 @@ module Hobo
373
395
  options = args.extract_options!
374
396
  target = args.empty? || args.first.is_a?(Symbol) ? this : args.shift
375
397
  action = args.first
398
+ return false if action.nil? && target.try.new_record?
376
399
 
377
400
  if target.respond_to?(:member_class) && (origin = target.try.origin)
378
401
  klass = origin.class
@@ -389,28 +412,32 @@ module Hobo
389
412
  action ||= :show
390
413
  end
391
414
 
392
- Hobo::ModelRouter.linkable?(klass, action, options.reverse_merge(:subsite => subsite))
415
+ Hobo::Routes.linkable?(klass, action, options.reverse_merge(:subsite => subsite))
393
416
  end
394
-
395
-
417
+
418
+
396
419
  def css_data(name, *args)
397
420
  "#{name.to_s.dasherize}::#{args * '::'}"
398
421
  end
399
-
422
+
400
423
 
401
424
  # --- ViewHint Helpers --- #
402
-
425
+
403
426
  def this_field_name
404
- this_parent.class.try.view_hints.try.field_name(this_field) || this_field
427
+ this_parent.class.try.human_attribute_name(this_field) || this_field
405
428
  end
406
429
 
407
430
  def this_field_help
408
- key = "#{this_parent.class.try.name.tableize}.hints.#{this_field.to_s}"
409
- default = this_parent.class.try.view_hints.try.field_help[this_field.to_sym] || ""
410
- Hobo::Translations.ht(key, :default=>default)
431
+ this_parent.class.try.attribute_help(this_field.to_sym) || ""
411
432
  end
412
433
 
413
434
 
435
+ # --- default Helpers --- #
436
+
437
+ def your_default
438
+ this == current_user ? "Your" : (this.name.ends_with?('s') ? "#{this.name}'" : "#{this.name}'s")
439
+ end
440
+
414
441
  # --- Debugging Helpers ---- #
415
442
 
416
443
  def abort_with(*args)
@@ -424,7 +451,7 @@ module Hobo
424
451
  logger.debug("DRYML THIS = #{this.typed_id rescue this.inspect}")
425
452
  logger.debug("###################\n")
426
453
  args.first unless args.empty?
427
- end
454
+ end
428
455
 
429
456
  end
430
457
 
@@ -0,0 +1,54 @@
1
+ module Hobo
2
+ module Helper
3
+ module Translations
4
+
5
+ include Normalizer
6
+
7
+ =begin
8
+
9
+ hobo_translate / ht
10
+
11
+ Wrapper around the Rails :translate helper with hobo added features.
12
+
13
+ It can be used as a regular helper or as a dryml tag.
14
+
15
+ Hobo Added Features
16
+
17
+ The first part of the key must be a model name (e.g.: user.index.title -> user). This method will add a "model" interpolation variable set to the translated and pluralized Model.model_name.human. Besides, it will add a default 'hobo.' fallback, (e.g.: hobo.index.title) at the beginning of the fallback chain.
18
+
19
+ You can also pass any other :translate option like for example :count.
20
+
21
+ Example:
22
+
23
+ <%= ht :key=>'user.index.title', :default=>'Index' %>
24
+ <ht key="user.index.title">Index</ht>
25
+ #=> "Index" # if "user.index.title" or "hobo.index.title" is not found
26
+ #=> "User Index" # with the below en.yml file
27
+
28
+ === en.yml ===
29
+ en:
30
+ hobo:
31
+ index:
32
+ title: %{model} Index
33
+
34
+ =end
35
+
36
+ def hobo_translate(*args)
37
+ key, options = normalize_args(*args)
38
+ keys = key.to_s.split(".")
39
+ model_name = keys.shift
40
+ model_class = begin model_name.camelize.constantize; rescue; end
41
+ unless model_class && model_class < ActiveRecord::Base
42
+ raise Hobo::I18nError, %(wrong model name: "#{model_name}" (extracted from translation key: "#{key}"). You might want to use the translate/t tag/method instead.)
43
+ end
44
+ options[:default].unshift("hobo.#{keys.join(".")}".to_sym)
45
+ options[:model] = model_class.model_name.human(:count=>options[:count]||1)
46
+ translate key.to_sym, options
47
+ end
48
+ alias_method :ht, :hobo_translate
49
+
50
+
51
+
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,39 @@
1
+ require 'active_support/core_ext/string/output_safety'
2
+ module Hobo
3
+ module Helper
4
+ module Translations
5
+ module Normalizer
6
+
7
+ private
8
+
9
+ def normalize_args(key, options={})
10
+ if (key.class == Hash) # called as a tag
11
+ if key.has_key?(:default) && !key[:default].blank?
12
+ Rails.logger.warn "hobo-i18n: 'default' should not be used as an attribute on *translate tags. If used, then you need to make sure that the tags inner-contents are not used. These are normally treated as defaults automatically, but if there is a default attribute then that inner-content will be hidden from this method - and will not be replaced with the translation found."
13
+ end
14
+ defaults = options[:default]
15
+ options = key
16
+ key = options.delete(:key)
17
+ # Set options[:default] to complete the tag-argument-conversion process.
18
+ options[:default] = defaults.call(options) if defaults.class == Proc
19
+ end
20
+ escape_options(options)
21
+ options[:default] = Array.wrap options[:default]
22
+ [key, options]
23
+ end
24
+
25
+ def escape_options(options)
26
+ options.each_pair do |k,v|
27
+ options[k] = case v
28
+ when Array
29
+ v.map {|i| i.respond_to?(:html_safe) ? ERB::Util.html_escape(i) : i}
30
+ else
31
+ v.respond_to?(:html_safe) ? ERB::Util.html_escape(v) : v
32
+ end
33
+ end
34
+ end
35
+
36
+ end
37
+ end
38
+ end
39
+ end
data/lib/hobo/model.rb CHANGED
@@ -14,15 +14,17 @@ module Hobo
14
14
 
15
15
  register_model(base)
16
16
 
17
+ patch_will_paginate
18
+
17
19
  base.class_eval do
18
20
  inheriting_cattr_reader :default_order
19
21
  alias_method_chain :attributes=, :hobo_type_conversion
20
22
 
21
- include Hobo::Permissions
22
- include Hobo::Lifecycles::ModelExtensions
23
- include Hobo::FindFor
24
- include Hobo::AccessibleAssociations
25
- include Hobo::Translations
23
+ include Permissions
24
+ include Lifecycles::ModelExtensions
25
+ include FindFor
26
+ include AccessibleAssociations
27
+ include IncludeInSave
26
28
  end
27
29
 
28
30
  class << base
@@ -33,21 +35,18 @@ module Hobo
33
35
  alias_method_chain :has_one, :new_method
34
36
 
35
37
  # eval avoids the ruby 1.9.2 "super from singleton method ..." error
36
- # see LH#840
37
38
  eval %(
38
- def inherited(klass)
39
- super
40
- fields(false) do
41
- Hobo.register_model(klass)
42
- field(klass.inheritance_column, :string)
43
- end
39
+ def inherited(klass)
40
+ super
41
+ fields(false) do
42
+ Hobo.register_model(klass)
43
+ field(klass.inheritance_column, :string)
44
44
  end
45
+ end
45
46
  )
46
47
  end
47
48
 
48
- # https://hobo.lighthouseapp.com/projects/8324/tickets/762-hobo_model-outside-a-full-rails-env-can-lead-to-stack-level-too-deep
49
- raise HoboError, "HoboFields.enable has not been called" unless base.respond_to?(:fields)
50
- base.fields(false) # force hobofields to load
49
+ base.fields(false) # force hobo_fields to load
51
50
 
52
51
  included_in_class_callbacks(base)
53
52
  end
@@ -59,10 +58,10 @@ module Hobo
59
58
  attr_accessor :member_class, :origin, :origin_attribute
60
59
  end
61
60
 
62
- WillPaginate::Finder::ClassMethods.class_eval do
61
+ WillPaginate::Finders::Base.class_eval do
63
62
  def paginate_with_hobo_metadata(*args, &block)
64
63
  collection = paginate_without_hobo_metadata(*args, &block)
65
- collection.member_class = self
64
+ collection.member_class = self.is_a?(ActiveRecord::Relation) ? member_class : self
66
65
  collection.origin = try.proxy_owner
67
66
  collection.origin_attribute = try.proxy_reflection._?.name
68
67
  collection
@@ -73,8 +72,8 @@ module Hobo
73
72
 
74
73
  end
75
74
  end
76
-
77
-
75
+
76
+
78
77
  def self.register_model(model)
79
78
  @model_names ||= Set.new
80
79
  @model_names << model.name
@@ -84,7 +83,7 @@ module Hobo
84
83
  def self.all_models
85
84
  # Load every model in app/models...
86
85
  unless @models_loaded
87
- Dir.entries("#{RAILS_ROOT}/app/models/").each do |f|
86
+ Dir.entries("#{Rails.root}/app/models/").each do |f|
88
87
  f =~ /^[a-zA-Z_][a-zA-Z0-9_]*\.rb$/ and f.sub(/.rb$/, '').camelize.constantize
89
88
  end
90
89
  @models_loaded = true
@@ -96,8 +95,8 @@ module Hobo
96
95
  name.safe_constantize || (@model_names.delete name; nil)
97
96
  end.compact
98
97
  end
99
-
100
-
98
+
99
+
101
100
  def self.find_by_typed_id(typed_id)
102
101
  return nil if typed_id == 'nil'
103
102
 
@@ -118,47 +117,16 @@ module Hobo
118
117
  end
119
118
 
120
119
 
121
- def self.enable
122
- require 'active_record/association_collection'
123
- require 'active_record/association_proxy'
124
- require 'active_record/association_reflection'
125
-
126
- ActiveRecord::Base.class_eval do
127
- def self.hobo_model
128
- if self.ancestors.include?(Hobo::Model)
129
- Rails.logger.error "#{self}: Do not call hobo_model in derived classes."
130
- else
131
- include Hobo::Model
132
- fields(false) # force hobofields to load
133
- end
134
- end
135
- def self.hobo_user_model
136
- include Hobo::Model
137
- include Hobo::User
138
- end
139
- alias_method :has_hobo_method?, :respond_to_without_attributes?
140
-
141
- Hobo::Permissions.enable
142
- end
143
-
144
- patch_will_paginate
145
- end
146
-
147
-
148
120
  module ClassMethods
149
- require 'active_record/viewhints_validations_interceptor'
150
- include Hobo::ViewHintsValidationsInterceptor
151
121
 
152
122
  # TODO: should this be an inheriting_cattr_accessor as well? Probably.
153
123
  attr_accessor :creator_attribute
154
124
  inheriting_cattr_accessor :name_attribute => Proc.new { |c|
155
- names = c.columns.*.name + c.public_instance_methods.*.to_s
156
- NAME_FIELD_GUESS.detect {|f| f.in? names }
125
+ NAME_FIELD_GUESS.detect {|f| f.in? c.send(:attrib_names) }
157
126
  }
158
127
 
159
128
  inheriting_cattr_accessor :primary_content_attribute => Proc.new { |c|
160
- names = c.columns.*.name + c.public_instance_methods.*.to_s
161
- PRIMARY_CONTENT_GUESS.detect {|f| f.in? names }
129
+ PRIMARY_CONTENT_GUESS.detect {|f| f.in? c.send(:attrib_names) }
162
130
  }
163
131
 
164
132
 
@@ -174,13 +142,17 @@ module Hobo
174
142
  self.creator_attribute = name.to_sym if options.delete(:creator)
175
143
  validate = options.delete(:validate) {true}
176
144
 
177
- #FIXME - this should be in Hobo::User
145
+ #FIXME - this should be in Hobo::Model::UserBase
178
146
  send(:login_attribute=, name.to_sym, validate) if options.delete(:login) && respond_to?(:login_attribute=)
179
147
  end
180
148
 
181
-
182
149
  private
183
150
 
151
+ def attrib_names
152
+ names = []
153
+ names += table_exists? ? content_columns.*.name : field_specs.keys
154
+ names += public_instance_methods.*.to_s
155
+ end
184
156
 
185
157
  def belongs_to_with_creator_metadata(name, options={}, &block)
186
158
  self.creator_attribute = name.to_sym if options.delete(:creator)
@@ -263,29 +235,13 @@ module Hobo
263
235
  end
264
236
 
265
237
 
266
- def find(*args, &b)
267
- options = args.extract_options!
268
- if options[:order] == :default || (options[:order].blank? && !scoped?(:find, :order))
269
- # TODO: decide if this is correct. AR is no help, as passing :order to a scoped proxy
270
- # MERGES the order, but nesting two scopes with :order completely ignores the
271
- # first scope's order.
272
- # Are we more like default_scope, or more like passing :order => model.default_order?
273
- options = if default_order.blank?
274
- options.except :order
275
- else
276
- options.merge(:order => if default_order[/(\.|\(|,| )/]
277
- default_order
278
- else
279
- "#{quoted_table_name}.#{default_order}"
280
- end)
281
- end
282
- end
283
- result = super(*args + [options])
238
+ def find(*args)
239
+ result = super
284
240
  result.member_class = self if result.is_a?(Array)
285
241
  result
286
242
  end
287
-
288
-
243
+
244
+
289
245
  def find_by_sql(*args)
290
246
  result = super
291
247
  result.member_class = self # find_by_sql always returns array
@@ -307,21 +263,21 @@ module Hobo
307
263
  def reverse_reflection(association_name)
308
264
  refl = reflections[association_name.to_sym] or raise "No reverse reflection for #{name}.#{association_name}"
309
265
  return nil if refl.options[:conditions] || refl.options[:polymorphic]
310
-
266
+
311
267
  if refl.macro == :has_many && (self_to_join = refl.through_reflection)
312
268
  # Find the reverse of a has_many :through (another has_many :through)
313
-
269
+
314
270
  join_to_self = reverse_reflection(self_to_join.name)
315
271
  join_to_other = refl.source_reflection
316
272
  other_to_join = self_to_join.klass.reverse_reflection(join_to_other.name)
317
-
273
+
318
274
  return nil if self_to_join.options[:conditions] || join_to_other.options[:conditions]
319
-
275
+
320
276
  refl.klass.reflections.values.find do |r|
321
277
  r.macro == :has_many &&
322
278
  !r.options[:conditions] &&
323
279
  !r.options[:scope] &&
324
- r.through_reflection == other_to_join &&
280
+ r.through_reflection == other_to_join &&
325
281
  r.source_reflection == join_to_self
326
282
  end
327
283
  else
@@ -333,7 +289,7 @@ module Hobo
333
289
  when :belongs_to
334
290
  [:has_many, :has_one]
335
291
  end
336
-
292
+
337
293
  refl.klass.reflections.values.find do |r|
338
294
  r.macro.in?(reverse_macros) &&
339
295
  r.klass >= self &&
@@ -361,7 +317,7 @@ module Hobo
361
317
 
362
318
 
363
319
  def respond_to?(method, include_private=false)
364
- super || create_automatic_scope(method)
320
+ super || create_automatic_scope(method, true)
365
321
  end
366
322
 
367
323
 
@@ -373,11 +329,24 @@ module Hobo
373
329
  def typed_id
374
330
  HoboFields.to_name(self) || name.underscore.gsub("/", "__")
375
331
  end
376
-
377
-
332
+
333
+
378
334
  def view_hints
379
335
  class_name = "#{name}Hints"
380
- class_name.safe_constantize or Object.class_eval("class #{class_name} < Hobo::ViewHints; end; #{class_name}")
336
+ class_name.safe_constantize or Object.class_eval("class #{class_name} < Hobo::Model::ViewHints; end; #{class_name}")
337
+ end
338
+
339
+ def children(*args)
340
+ view_hints.children *args
341
+ end
342
+
343
+ def inline_booleans(*args)
344
+ view_hints.inline_booleans *args
345
+ end
346
+
347
+ def table_exists?
348
+ @table_exists_cache = super if @table_exists_cache.nil?
349
+ @table_exists_cache
381
350
  end
382
351
 
383
352
 
@@ -388,10 +357,10 @@ module Hobo
388
357
 
389
358
 
390
359
  def to_url_path
391
- "#{self.class.to_url_path}/#{to_param}" unless new_record?
360
+ "#{self.class.to_url_path}/#{to_param}"
392
361
  end
393
-
394
-
362
+
363
+
395
364
  def to_param
396
365
  name_attr = self.class.name_attribute and name = send(name_attr)
397
366
  if name_attr && !name.blank? && id.is_a?(Fixnum)
@@ -451,7 +420,7 @@ module Hobo
451
420
  if self.class.name_attribute
452
421
  send self.class.name_attribute
453
422
  else
454
- "#{self.class.name.titleize} #{id}"
423
+ "#{self.class.model_name.human} #{id}"
455
424
  end
456
425
  end
457
426
 
@@ -481,7 +450,7 @@ module Hobo
481
450
  if parts[0..2].include?(0)
482
451
  nil
483
452
  else
484
- Time.zone ? Time.zone.local(*parts) : Time.local(*parts)
453
+ field_type <= Time ? Time.utc(*parts) : Time.zone.local(*parts)
485
454
  end
486
455
  else
487
456
  value
@@ -500,6 +469,3 @@ module Hobo
500
469
  end
501
470
 
502
471
  end
503
-
504
-
505
- Hobo::Model.enable if defined? ActiveRecord