hobo 1.4.0.pre6 → 1.4.0.pre7
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES-1.3.txt +1 -1
- data/CHANGES-1.4.txt +42 -0
- data/TODO-1.4.txt +6 -5
- data/VERSION +1 -1
- data/app/helpers/hobo_permissions_helper.rb +1 -1
- data/app/helpers/hobo_route_helper.rb +8 -3
- data/lib/generators/hobo/front_controller/front_controller_generator.rb +1 -0
- data/lib/generators/hobo/routes/router.rb +1 -1
- data/lib/hobo.rb +2 -1
- data/lib/hobo/controller.rb +1 -0
- data/lib/hobo/controller/cache.rb +35 -0
- data/lib/hobo/controller/model.rb +85 -68
- data/lib/hobo/engine.rb +10 -0
- data/lib/hobo/extensions/active_record/permissions.rb +5 -1
- data/lib/hobo/extensions/active_support/cache/file_store.rb +18 -0
- data/lib/hobo/model.rb +2 -2
- metadata +8 -6
data/CHANGES-1.3.txt
CHANGED
@@ -29,7 +29,7 @@ Examples
|
|
29
29
|
|
30
30
|
# Configuration Variables #
|
31
31
|
|
32
|
-
They are set by the hobo engine at startup, and they can be
|
32
|
+
They are set by the hobo engine at startup, and they can be overwritten by adding in `config/application.rb`:
|
33
33
|
|
34
34
|
config.hobo.<variable_name> = <value>
|
35
35
|
|
data/CHANGES-1.4.txt
CHANGED
@@ -354,6 +354,10 @@ If you have malsup's form plugin installed, Ajax file uploads should
|
|
354
354
|
"just work", as long as you don't have debug_rjs turned on in your
|
355
355
|
config/initializers/development.rb.
|
356
356
|
|
357
|
+
Make sure you're form uses multipart encoding:
|
358
|
+
|
359
|
+
<form multipart ajax/>
|
360
|
+
|
357
361
|
### AJAX events
|
358
362
|
|
359
363
|
The standard 'before', 'success', 'done' and 'error' callbacks may
|
@@ -438,6 +442,8 @@ of new options that control how the spinner is displayed.
|
|
438
442
|
- spinner-options: passed to [jQuery-UI's position](http://jqueryui.com/demos/position/). Defaults are `{my: 'right bottom', at: 'left top'}`
|
439
443
|
- message: the message to display inside the spinner
|
440
444
|
|
445
|
+
The above attributes may be added to most tags that accept the standard ajax attributes.
|
446
|
+
|
441
447
|
These options may be overridden globally by adding them as attributes to the `page-scripts` parameter for the page.
|
442
448
|
|
443
449
|
<extend tag="page">
|
@@ -511,6 +517,11 @@ The helper functions have been renamed. For instance,
|
|
511
517
|
Dialog positioning has been updated and should work better now. See
|
512
518
|
the documentation for more details.
|
513
519
|
|
520
|
+
### search-filter
|
521
|
+
|
522
|
+
The table-plus search filter has been extracted into its own tag for
|
523
|
+
use outside of table-plus. It has also gained a "clear" button.
|
524
|
+
|
514
525
|
### live-search
|
515
526
|
|
516
527
|
`live-search` works in a substantially different fashion now, it has
|
@@ -545,6 +556,37 @@ if you still need it.
|
|
545
556
|
There's a new helper function called query_parameters_filtered that
|
546
557
|
returns query parameters with the ajax parameters removed.
|
547
558
|
|
559
|
+
### parse_sort_param
|
560
|
+
|
561
|
+
The controller function parse_sort_param has been updated so that it
|
562
|
+
can take a hash instead of or as well as an argument list. The key of
|
563
|
+
the hash is the field name and the value is the column name.
|
564
|
+
Example:
|
565
|
+
|
566
|
+
Book.include(:authors).order(parse_sort_param(:title, :authors => "authors.last_name")
|
567
|
+
|
568
|
+
parse_sort_param now also pluralizes table names. For example, if the
|
569
|
+
field is named "project.title", parse_sort_param will sort on the
|
570
|
+
column "projects.title".
|
571
|
+
|
572
|
+
### controller actions
|
573
|
+
|
574
|
+
Hobo no longer attempts to perform its part-based AJAX actions when
|
575
|
+
sent an xhr request. Instead, Hobo performs part-based AJAX when
|
576
|
+
params[:render] is set.
|
577
|
+
|
578
|
+
The signature for the function update_response and friends has changed. This should make it useful for use in your application. It can be used like this:
|
579
|
+
|
580
|
+
def update
|
581
|
+
hobo_update do
|
582
|
+
if params[:foo]==17
|
583
|
+
render_my_way
|
584
|
+
else
|
585
|
+
update_response # let Hobo handle it all
|
586
|
+
end
|
587
|
+
end
|
588
|
+
end
|
589
|
+
|
548
590
|
## Editors
|
549
591
|
|
550
592
|
Editors are no longer special-cased, they now use the standard DRYML
|
data/TODO-1.4.txt
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
## regressions
|
4
4
|
|
5
|
-
*
|
5
|
+
* sortable-input-many does not work
|
6
6
|
* remote-method-button, create-button, update-button,
|
7
7
|
transition-button: normal usages of these tags work, but they do
|
8
8
|
not work if you ask them to do AJAX
|
@@ -24,6 +24,8 @@
|
|
24
24
|
* admin subsite
|
25
25
|
* books
|
26
26
|
* ajax manual section
|
27
|
+
* miscellaneous controller extensions
|
28
|
+
* there's some nice stuff in HoboFields::Model that should be documented & tested
|
27
29
|
|
28
30
|
## Cookbook
|
29
31
|
|
@@ -34,11 +36,8 @@
|
|
34
36
|
|
35
37
|
## new features that aren't "done"
|
36
38
|
|
37
|
-
* create_response: mirror update_response
|
38
|
-
* taglib cleanup
|
39
39
|
* clean_sidemenu -> plugin
|
40
|
-
*
|
41
|
-
* nested-cache: enhanced sweeper version
|
40
|
+
* cache: csrf warning
|
42
41
|
* monkey patch will_paginate if my patches are not upstreamed
|
43
42
|
|
44
43
|
It's quite likely that some of the new tag definitions are missing
|
@@ -48,6 +47,8 @@ you notice any such omissions, please let us know, it is easy to fix..
|
|
48
47
|
|
49
48
|
## stuff that we really want to do
|
50
49
|
|
50
|
+
* multiple file support for AJAX uploads
|
51
|
+
* cache: redis support
|
51
52
|
* fixup deprecation warnings
|
52
53
|
* port to Rails 3.2 and/or 4.0
|
53
54
|
* nuke any remaining prototype code
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.4.0.
|
1
|
+
1.4.0.pre7
|
@@ -21,7 +21,7 @@ module HoboPermissionsHelper
|
|
21
21
|
object = object.new
|
22
22
|
elsif (refl = object.try.proxy_reflection) && refl.macro == :has_many
|
23
23
|
if Hobo.simple_has_many_association?(object)
|
24
|
-
object = object.
|
24
|
+
object = object.build
|
25
25
|
object.set_creator(current_user)
|
26
26
|
else
|
27
27
|
return false
|
@@ -2,7 +2,7 @@ module HoboRouteHelper
|
|
2
2
|
extend HoboHelperBase
|
3
3
|
protected
|
4
4
|
def base_url
|
5
|
-
|
5
|
+
ENV['RAILS_RELATIVE_URL_ROOT'] || ''
|
6
6
|
end
|
7
7
|
|
8
8
|
def controller_for(obj)
|
@@ -41,7 +41,7 @@ module HoboRouteHelper
|
|
41
41
|
if method.to_s == 'post'
|
42
42
|
action = :"create_for_#{owner_name}"
|
43
43
|
else
|
44
|
-
|
44
|
+
action = :"index_for_#{owner_name}"
|
45
45
|
end
|
46
46
|
end
|
47
47
|
klass = obj.member_class
|
@@ -112,7 +112,12 @@ O action = :"index_for_#{owner_name}"
|
|
112
112
|
def recognize_page_path
|
113
113
|
# round tripping params through the router will remove
|
114
114
|
# unnecessary params
|
115
|
-
|
115
|
+
url = params[:page_path] || url_for(params)
|
116
|
+
if ENV['RAILS_RELATIVE_URL_ROOT']
|
117
|
+
url.gsub!(/^#{ENV['RAILS_RELATIVE_URL_ROOT']}/, "")
|
118
|
+
url.gsub!(/^https?:\/\/.*?#{ENV['RAILS_RELATIVE_URL_ROOT']}/, "")
|
119
|
+
end
|
120
|
+
Rails.application.routes.recognize_path(url)
|
116
121
|
end
|
117
122
|
|
118
123
|
def url_for_page_path(options={})
|
@@ -46,6 +46,7 @@ module Hobo
|
|
46
46
|
route "match 'search' => '#{file_path}#search', :as => 'site_search'"
|
47
47
|
if class_path.empty?
|
48
48
|
route "root :to => '#{file_path}#index'"
|
49
|
+
route "match ENV['RAILS_RELATIVE_URL_ROOT'] => 'front#index' if ENV['RAILS_RELATIVE_URL_ROOT']"
|
49
50
|
else
|
50
51
|
route "match '#{file_path}' => '#{file_path}#index', :as => '#{file_path.gsub(/\//,'_')}'"
|
51
52
|
end
|
@@ -40,7 +40,7 @@ module Generators
|
|
40
40
|
def resource_routes
|
41
41
|
[
|
42
42
|
link("get '#{records}(.:format)' => '#{records}#index', :as => '#{records}'", 'index'),
|
43
|
-
link("get '#{records}/new(.:format)', :as => 'new_#{record}'", 'new'),
|
43
|
+
link("get '#{records}/new(.:format)' => '#{records}#new', :as => 'new_#{record}'", 'new'),
|
44
44
|
link("get '#{records}/:id/edit(.:format)' => '#{records}#edit', :as => 'edit_#{record}'", 'edit'),
|
45
45
|
link("get '#{records}/:id(.:format)' => '#{records}#show', :as => '#{record}', :constraints => #{ID_REQUIREMENT}", 'show'),
|
46
46
|
link("post '#{records}(.:format)' => '#{records}#create', :as => 'create_#{record}'", 'create', :post),
|
data/lib/hobo.rb
CHANGED
data/lib/hobo/controller.rb
CHANGED
@@ -0,0 +1,35 @@
|
|
1
|
+
module Hobo
|
2
|
+
module Controller
|
3
|
+
module Cache
|
4
|
+
def expire_swept_caches_for(obj, attr=nil)
|
5
|
+
typed_id = if attr.nil?
|
6
|
+
if obj.respond_to?(:typed_id)
|
7
|
+
obj.typed_id
|
8
|
+
else
|
9
|
+
obj.to_s
|
10
|
+
end
|
11
|
+
else
|
12
|
+
"#{obj.typed_id}:#{attr}"
|
13
|
+
end
|
14
|
+
sweep_key = ActiveSupport::Cache.expand_cache_key(typed_id, :sweep_key)
|
15
|
+
if Hobo.stable_cache.respond_to?(:read_matched)
|
16
|
+
Hobo.stable_cache.read_matched(/#{sweep_key}/).each do |k,v|
|
17
|
+
key=k[sweep_key.length+1..-1]
|
18
|
+
Rails.logger.debug "CACHE DELETING #{key}"
|
19
|
+
Rails.cache.delete(key)
|
20
|
+
Hobo.stable_cache.delete(k)
|
21
|
+
end
|
22
|
+
else
|
23
|
+
keys = Hobo.stable_cache.read(sweep_key)
|
24
|
+
return if keys.nil? || keys.empty?
|
25
|
+
keys.each do |key|
|
26
|
+
Rails.logger.debug "CACHE DELETING #{key}"
|
27
|
+
Rails.cache.delete(key)
|
28
|
+
end
|
29
|
+
Hobo.stable_cache.delete(sweep_key)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -330,20 +330,26 @@ module Hobo
|
|
330
330
|
protected
|
331
331
|
|
332
332
|
|
333
|
-
def parse_sort_param(*
|
333
|
+
def parse_sort_param(*args)
|
334
334
|
_, desc, field = *params[:sort]._?.match(/^(-)?([a-z_]+(?:\.[a-z_]+)?)$/)
|
335
335
|
|
336
336
|
if field
|
337
|
-
|
337
|
+
hash = args.extract_options!
|
338
|
+
db_sort_field = (hash[field] || hash[field.to_sym] || (field if field.in?(args) || field.to_sym.in?(args))).to_s
|
339
|
+
|
340
|
+
if db_sort_field
|
341
|
+
if db_sort_field == field && field.match(/\./)
|
342
|
+
fields = field.split(".", 2)
|
343
|
+
db_sort_field = "#{fields[0].pluralize}.#{fields[1]}"
|
344
|
+
end
|
338
345
|
@sort_field = field
|
339
346
|
@sort_direction = desc ? "desc" : "asc"
|
340
347
|
|
341
|
-
|
348
|
+
"#{db_sort_field} #{@sort_direction}"
|
342
349
|
end
|
343
350
|
end
|
344
351
|
end
|
345
352
|
|
346
|
-
|
347
353
|
# --- Action implementation helpers --- #
|
348
354
|
|
349
355
|
|
@@ -476,7 +482,7 @@ module Hobo
|
|
476
482
|
options = args.extract_options!
|
477
483
|
finder = args.first || model
|
478
484
|
self.this ||= find_or_paginate(finder, options)
|
479
|
-
|
485
|
+
response_block(&b) || index_response
|
480
486
|
end
|
481
487
|
|
482
488
|
|
@@ -485,7 +491,7 @@ module Hobo
|
|
485
491
|
owner, association = find_owner_and_association(owner)
|
486
492
|
finder = args.first || association
|
487
493
|
self.this ||= find_or_paginate(finder, options)
|
488
|
-
|
494
|
+
response_block(&b) || index_response
|
489
495
|
end
|
490
496
|
|
491
497
|
|
@@ -498,7 +504,7 @@ module Hobo
|
|
498
504
|
this.with_acting_user(current_user) { this.attributes = parms }
|
499
505
|
end
|
500
506
|
end
|
501
|
-
|
507
|
+
response_block(&b) || show_response
|
502
508
|
end
|
503
509
|
|
504
510
|
def hobo_edit(*args, &b)
|
@@ -507,33 +513,27 @@ module Hobo
|
|
507
513
|
|
508
514
|
def hobo_new(record=nil, &b)
|
509
515
|
self.this = record || model.user_new(current_user, attribute_parameters)
|
510
|
-
|
516
|
+
response_block(&b) || show_response
|
511
517
|
end
|
512
518
|
|
513
|
-
def show_response
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
render :nothing => true unless performed?
|
519
|
-
end
|
520
|
-
end
|
519
|
+
def show_response
|
520
|
+
if request.xhr? && params[:render]
|
521
|
+
hobo_ajax_response
|
522
|
+
render :nothing => true unless performed?
|
523
|
+
end
|
521
524
|
end
|
522
525
|
|
523
|
-
def index_response
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
render :nothing => true unless performed?
|
529
|
-
end
|
530
|
-
end
|
526
|
+
def index_response
|
527
|
+
if request.xhr? && params[:render]
|
528
|
+
hobo_ajax_response(:page => :blah)
|
529
|
+
render :nothing => true unless performed?
|
530
|
+
end
|
531
531
|
end
|
532
532
|
|
533
533
|
def hobo_new_for(owner, record=nil, &b)
|
534
534
|
owner, association = find_owner_and_association(owner)
|
535
535
|
self.this = record || association.user_new(current_user, attribute_parameters)
|
536
|
-
|
536
|
+
response_block(&b) || show_response
|
537
537
|
end
|
538
538
|
|
539
539
|
|
@@ -546,7 +546,7 @@ module Hobo
|
|
546
546
|
self.this = new_for_create(attributes)
|
547
547
|
this.user_save(current_user)
|
548
548
|
end
|
549
|
-
create_response(:new, options
|
549
|
+
response_block(&b) || create_response(:new, options)
|
550
550
|
end
|
551
551
|
|
552
552
|
|
@@ -560,7 +560,7 @@ module Hobo
|
|
560
560
|
self.this = association.new(attributes)
|
561
561
|
this.save
|
562
562
|
end
|
563
|
-
create_response(:"new_for_#{name_of_auto_action_for(owner_association)}", options
|
563
|
+
response_block(&b) || create_response(:"new_for_#{name_of_auto_action_for(owner_association)}", options)
|
564
564
|
end
|
565
565
|
|
566
566
|
|
@@ -589,45 +589,6 @@ module Hobo
|
|
589
589
|
def create_response(new_action, options={}, &b)
|
590
590
|
flash_notice (ht( :"#{@this.class.to_s.underscore}.messages.create.success", :default=>["The #{@this.class.model_name.human} was created successfully"])) if valid?
|
591
591
|
|
592
|
-
response_block(&b) or
|
593
|
-
if valid?
|
594
|
-
respond_to do |wants|
|
595
|
-
wants.html { redirect_after_submit(options) }
|
596
|
-
wants.js { hobo_ajax_response || render(:nothing => true) }
|
597
|
-
end
|
598
|
-
else
|
599
|
-
respond_to do |wants|
|
600
|
-
# errors is used by the translation helper, ht, below.
|
601
|
-
errors = this.errors.full_messages.join("\n")
|
602
|
-
wants.html { re_render_form(new_action) }
|
603
|
-
wants.js { render(:status => 500,
|
604
|
-
:text => ht( :"#{this.class.to_s.underscore}.messages.create.error", :errors=>errors,:default=>["Couldn't create the #{this.class.name.titleize.downcase}.\n #{errors}"])
|
605
|
-
)}
|
606
|
-
end
|
607
|
-
end
|
608
|
-
end
|
609
|
-
|
610
|
-
|
611
|
-
def hobo_update(*args, &b)
|
612
|
-
options = args.extract_options!
|
613
|
-
|
614
|
-
self.this ||= args.first || find_instance
|
615
|
-
changes = options[:attributes] || attribute_parameters or raise RuntimeError, t("hobo.messages.update.no_attribute_error", :default=>["No update specified in params"])
|
616
|
-
|
617
|
-
if this.user_update_attributes(current_user, changes)
|
618
|
-
# Ensure current_user isn't out of date
|
619
|
-
@current_user = @this if @this == current_user
|
620
|
-
end
|
621
|
-
|
622
|
-
in_place_edit_field = changes.keys.first if changes.size == 1 && params[:render]
|
623
|
-
update_response(in_place_edit_field, options, &b)
|
624
|
-
end
|
625
|
-
|
626
|
-
|
627
|
-
def update_response(in_place_edit_field=nil, options={}, &b)
|
628
|
-
|
629
|
-
flash_notice (ht(:"#{@this.class.to_s.underscore}.messages.update.success", :default=>["Changes to the #{@this.class.model_name.human} were saved"])) if valid?
|
630
|
-
|
631
592
|
response_block(&b) or begin
|
632
593
|
valid = valid? # valid? can be expensive
|
633
594
|
if params[:render]
|
@@ -638,19 +599,75 @@ module Hobo
|
|
638
599
|
render :nothing => true unless performed?
|
639
600
|
else
|
640
601
|
errors = @this.errors.full_messages.join('\n')
|
641
|
-
message = ht(:"#{
|
602
|
+
message = ht( :"#{this.class.to_s.underscore}.messages.create.error", :errors=>errors,:default=>["Couldn't create the #{this.class.name.titleize.downcase}.\n #{errors}"])
|
642
603
|
ajax_response("alert('#{message}');", params[:render_options])
|
643
604
|
end
|
644
605
|
else
|
645
606
|
if valid
|
646
607
|
redirect_after_submit options
|
647
608
|
else
|
648
|
-
re_render_form(
|
609
|
+
re_render_form(new_action)
|
649
610
|
end
|
650
611
|
end
|
651
612
|
end
|
652
613
|
end
|
653
614
|
|
615
|
+
|
616
|
+
def hobo_update(*args, &b)
|
617
|
+
options = args.extract_options!
|
618
|
+
|
619
|
+
self.this ||= args.first || find_instance
|
620
|
+
changes = options[:attributes] || attribute_parameters or raise RuntimeError, t("hobo.messages.update.no_attribute_error", :default=>["No update specified in params"])
|
621
|
+
|
622
|
+
if this.user_update_attributes(current_user, changes)
|
623
|
+
# Ensure current_user isn't out of date
|
624
|
+
@current_user = @this if @this == current_user
|
625
|
+
end
|
626
|
+
|
627
|
+
response_block(&b) || update_response(nil, options)
|
628
|
+
end
|
629
|
+
|
630
|
+
|
631
|
+
# typically used like this:
|
632
|
+
# def update
|
633
|
+
# hobo_update do
|
634
|
+
# if params[:foo]==17
|
635
|
+
# render_my_way
|
636
|
+
# else
|
637
|
+
# update_response # let Hobo handle it all
|
638
|
+
# end
|
639
|
+
# end
|
640
|
+
# end
|
641
|
+
#
|
642
|
+
# parameters:
|
643
|
+
# valid is a cache of valid?
|
644
|
+
# options is passed through to redirect_after_submit
|
645
|
+
def update_response(valid=nil, options={})
|
646
|
+
# valid? can be expensive, cache it
|
647
|
+
valid = valid? if valid.nil?
|
648
|
+
if params[:render]
|
649
|
+
if (params[:render_options] && params[:render_options][:errors_ok]) || valid
|
650
|
+
hobo_ajax_response
|
651
|
+
|
652
|
+
# Maybe no ajax requests were made
|
653
|
+
render :nothing => true unless performed?
|
654
|
+
else
|
655
|
+
errors = @this.errors.full_messages.join('\n')
|
656
|
+
message = ht(:"#{@this.class.to_s.underscore}.messages.update.error", :default=>["There was a problem with that change\\n#{errors}"], :errors=>errors)
|
657
|
+
|
658
|
+
ajax_response("alert('#{message}');", params[:render_options])
|
659
|
+
end
|
660
|
+
else
|
661
|
+
if valid
|
662
|
+
flash_notice (ht(:"#{@this.class.to_s.underscore}.messages.update.success", :default=>["Changes to the #{@this.class.model_name.human} were saved"]))
|
663
|
+
|
664
|
+
redirect_after_submit options
|
665
|
+
else
|
666
|
+
re_render_form(:edit)
|
667
|
+
end
|
668
|
+
end
|
669
|
+
end
|
670
|
+
|
654
671
|
def hobo_destroy(*args, &b)
|
655
672
|
options = args.extract_options!
|
656
673
|
self.this ||= args.first || find_instance
|
data/lib/hobo/engine.rb
CHANGED
@@ -16,6 +16,7 @@ module Hobo
|
|
16
16
|
h.read_only_file_system = !!ENV['HEROKU_TYPE']
|
17
17
|
h.show_translation_keys = false
|
18
18
|
h.dryml_only_templates = false
|
19
|
+
h.stable_cache_store = nil
|
19
20
|
end
|
20
21
|
|
21
22
|
ActiveSupport.on_load(:action_controller) do
|
@@ -34,6 +35,7 @@ module Hobo
|
|
34
35
|
require 'hobo/extensions/active_record/relation_with_origin'
|
35
36
|
require 'hobo/extensions/active_model/name'
|
36
37
|
require 'hobo/extensions/active_model/translation'
|
38
|
+
require 'hobo/extensions/active_support/cache/file_store'
|
37
39
|
# added legacy namespace for backward compatibility
|
38
40
|
# TODO: remove the following line if Hobo::VERSION > 1.3.x
|
39
41
|
Hobo::ViewHints = Hobo::Model::ViewHints
|
@@ -76,5 +78,13 @@ module Hobo
|
|
76
78
|
end
|
77
79
|
end
|
78
80
|
|
81
|
+
initializer 'hobo.cache' do |app|
|
82
|
+
if app.config.hobo.stable_cache_store
|
83
|
+
Hobo.stable_cache = ActiveSupport::Cache.lookup_store(app.config.hobo.stable_cache_store)
|
84
|
+
else
|
85
|
+
Hobo.stable_cache = Rails.cache
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
79
89
|
end
|
80
90
|
end
|
@@ -42,7 +42,11 @@ ActiveRecord::Associations::HasManyAssociation.class_eval do
|
|
42
42
|
def insert_record_with_owner_attributes(record, force = true, raise = false)
|
43
43
|
set_owner_attributes(record)
|
44
44
|
if (user = acting_user) && record.is_a?(Hobo::Model)
|
45
|
-
|
45
|
+
if respond_to?(:with_acting_user)
|
46
|
+
with_acting_user(user) { insert_record_without_owner_attributes(record, force, raise) }
|
47
|
+
else
|
48
|
+
record.with_acting_user(user) { insert_record_without_owner_attributes(record, force, raise) }
|
49
|
+
end
|
46
50
|
else
|
47
51
|
insert_record_without_owner_attributes(record, force, raise)
|
48
52
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module ActiveSupport
|
2
|
+
module Cache
|
3
|
+
class FileStore
|
4
|
+
def hobo_read_matched(matcher, options = nil)
|
5
|
+
Enumerator.new do |y|
|
6
|
+
options = merged_options(options)
|
7
|
+
matcher = key_matcher(matcher, options)
|
8
|
+
search_dir(cache_path) do |path|
|
9
|
+
key = file_path_key(path)
|
10
|
+
y << [key, read_entry(key, options)] if key.match(matcher)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
alias_method(:read_matched, :hobo_read_matched) unless method_defined?(:read_matched)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/lib/hobo/model.rb
CHANGED
@@ -167,10 +167,10 @@ module Hobo
|
|
167
167
|
# (ie X belongs_to Y (polymorphic), Z is a subclass of Y; @x.y_is?(some_z) will never pass)
|
168
168
|
class_eval %{
|
169
169
|
def #{name}_is?(target)
|
170
|
-
target.class.name == self.#{refl.
|
170
|
+
target.class.name == self.#{refl.foreign_type} && target.#{id_method} == self.#{refl.foreign_key}
|
171
171
|
end
|
172
172
|
def #{name}_changed?
|
173
|
-
#{refl.foreign_key}_changed? || #{refl.
|
173
|
+
#{refl.foreign_key}_changed? || #{refl.foreign_type}_changed?
|
174
174
|
end
|
175
175
|
}
|
176
176
|
else
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: hobo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease: 6
|
5
|
-
version: 1.4.0.
|
5
|
+
version: 1.4.0.pre7
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Tom Locke
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2012-
|
13
|
+
date: 2012-07-05 00:00:00 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: hobo_support
|
@@ -20,7 +20,7 @@ dependencies:
|
|
20
20
|
requirements:
|
21
21
|
- - "="
|
22
22
|
- !ruby/object:Gem::Version
|
23
|
-
version: 1.4.0.
|
23
|
+
version: 1.4.0.pre7
|
24
24
|
type: :runtime
|
25
25
|
version_requirements: *id001
|
26
26
|
- !ruby/object:Gem::Dependency
|
@@ -31,7 +31,7 @@ dependencies:
|
|
31
31
|
requirements:
|
32
32
|
- - "="
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version: 1.4.0.
|
34
|
+
version: 1.4.0.pre7
|
35
35
|
type: :runtime
|
36
36
|
version_requirements: *id002
|
37
37
|
- !ruby/object:Gem::Dependency
|
@@ -42,7 +42,7 @@ dependencies:
|
|
42
42
|
requirements:
|
43
43
|
- - "="
|
44
44
|
- !ruby/object:Gem::Version
|
45
|
-
version: 1.4.0.
|
45
|
+
version: 1.4.0.pre7
|
46
46
|
type: :runtime
|
47
47
|
version_requirements: *id003
|
48
48
|
- !ruby/object:Gem::Dependency
|
@@ -226,6 +226,7 @@ files:
|
|
226
226
|
- lib/hobo.rb
|
227
227
|
- lib/hobo/controller.rb
|
228
228
|
- lib/hobo/controller/authentication_support.rb
|
229
|
+
- lib/hobo/controller/cache.rb
|
229
230
|
- lib/hobo/controller/model.rb
|
230
231
|
- lib/hobo/controller/user_base.rb
|
231
232
|
- lib/hobo/engine.rb
|
@@ -243,6 +244,7 @@ files:
|
|
243
244
|
- lib/hobo/extensions/active_record/hobo_methods.rb
|
244
245
|
- lib/hobo/extensions/active_record/permissions.rb
|
245
246
|
- lib/hobo/extensions/active_record/relation_with_origin.rb
|
247
|
+
- lib/hobo/extensions/active_support/cache/file_store.rb
|
246
248
|
- lib/hobo/extensions/array.rb
|
247
249
|
- lib/hobo/extensions/enumerable.rb
|
248
250
|
- lib/hobo/extensions/i18n.rb
|
@@ -328,7 +330,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
328
330
|
requirements: []
|
329
331
|
|
330
332
|
rubyforge_project: hobo
|
331
|
-
rubygems_version: 1.8.
|
333
|
+
rubygems_version: 1.8.21
|
332
334
|
signing_key:
|
333
335
|
specification_version: 3
|
334
336
|
summary: The web app builder for Rails
|