Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

proc -> block (with an argument).

  • Loading branch information...
commit 3426c26b6e16841608fb827ef87dfb63005d58da 1 parent 9e5e4e9
@emasaka emasaka authored
View
8 lib/plugins/defaults/auto_reload.rb
@@ -17,11 +17,9 @@
&auto_reload_proc
)
-config.set_assign_hook(
- :update_interval,
- lambda {
- Termtter::Client.task_manager.get_task(:auto_reload).interval =
- config.update_interval })
+config.set_assign_hook(:update_interval) do |v|
+ Termtter::Client.task_manager.get_task(:auto_reload).interval = v
+end
Termtter::Client.register_hook(
:name => :auto_reload_init,
View
6 lib/termtter/config.rb
@@ -31,8 +31,8 @@ def set_default(name, value)
end
end
- def set_assign_hook(name, proc)
- @assign_hook[name.to_sym] = proc
+ def set_assign_hook(name, &block)
+ @assign_hook[name.to_sym] = block
end
# call-seq:
@@ -63,7 +63,7 @@ def __unfreeze__(name)
def __assign__(name, value)
return if @freezes.include?(name)
@store[name] = value
- @assign_hook[name].call if @assign_hook[name]
+ @assign_hook[name].call(value) if @assign_hook[name]
value
end
View
4 spec/termtter/config_spec.rb
@@ -174,8 +174,8 @@ module Termtter
it 'executes assign hook' do
@config.set_default(:foo, nil)
flag = false
- @config.set_assign_hook(:foo, lambda { flag = true })
- @config.foo = 'foo'
+ @config.set_assign_hook(:foo) {|v| flag = v }
+ @config.foo = true
flag.should be_true
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.