simple_autocomplete 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.1
1
+ 0.3.2
@@ -30,7 +30,7 @@ end
30
30
  # items.map{|item| "#{item.title} -- #{item.id}"}.join("\n")
31
31
  # end
32
32
  class ActionController::Base
33
- def self.autocomplete_for(object, method, options = {})
33
+ def self.autocomplete_for(object, method, options = {}, &block)
34
34
  define_method("autocomplete_for_#{object}_#{method}") do
35
35
  model = object.to_s.camelize.constantize
36
36
  find_options = {
@@ -42,7 +42,7 @@ class ActionController::Base
42
42
  @items = model.scoped(find_options)
43
43
 
44
44
  out = if block_given?
45
- yield(@items)
45
+ instance_exec @items, &block
46
46
  else
47
47
  %Q[<%= @items.map {|item| h(item.#{method})}.uniq.join("\n")%>]
48
48
  end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{simple_autocomplete}
8
- s.version = "0.3.1"
8
+ s.version = "0.3.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Michael Grosser"]
12
- s.date = %q{2010-03-23}
12
+ s.date = %q{2010-04-14}
13
13
  s.email = %q{grosser.michael@gmail.com}
14
14
  s.extra_rdoc_files = [
15
15
  "README.markdown"
@@ -7,6 +7,9 @@ describe SimpleAutocomplete do
7
7
  end
8
8
 
9
9
  class UsersController < ActionController::Base
10
+ def a_instance_method
11
+ self.class.a_class_method
12
+ end
10
13
  end
11
14
 
12
15
  describe 'Controller extensions' do
@@ -86,6 +89,14 @@ describe 'Controller extensions' do
86
89
  @c.should_receive(:render).with(hash_including(:inline => 'aaxx'))
87
90
  @c.autocomplete_for_user_name
88
91
  end
92
+
93
+ it "has block in controllers scope" do
94
+ UsersController.should_receive(:a_class_method)
95
+ UsersController.autocomplete_for(:user, :name) do |items|
96
+ a_instance_method
97
+ end
98
+ @c.autocomplete_for_user_name
99
+ end
89
100
  end
90
101
  end
91
102
 
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 3
8
- - 1
9
- version: 0.3.1
8
+ - 2
9
+ version: 0.3.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Michael Grosser
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-03-23 00:00:00 +01:00
17
+ date: 2010-04-14 00:00:00 +02:00
18
18
  default_executable:
19
19
  dependencies: []
20
20