Class: Wee::Brush::RadioButtonTag::RadioGroup
- Defined in:
- lib/wee/renderer/html/brushes.rb
Instance Method Summary collapse
- #add_callback(callback) ⇒ Object
- #call(value) ⇒ Object
-
#initialize(canvas) ⇒ RadioGroup
constructor
A new instance of RadioGroup.
Constructor Details
#initialize(canvas) ⇒ RadioGroup
Returns a new instance of RadioGroup.
438 439 440 441 442 |
# File 'lib/wee/renderer/html/brushes.rb', line 438 def initialize(canvas) @name = canvas.register_callback(:input, self) @callbacks = {} @ids = Wee::SimpleIdGenerator.new end |
Instance Method Details
#add_callback(callback) ⇒ Object
444 445 446 447 448 |
# File 'lib/wee/renderer/html/brushes.rb', line 444 def add_callback(callback) value = @ids.next.to_s @callbacks[value] = callback return [@name, value] end |
#call(value) ⇒ Object
450 451 452 453 454 455 456 457 |
# File 'lib/wee/renderer/html/brushes.rb', line 450 def call(value) if @callbacks.has_key?(value) cb = @callbacks[value] cb.call(value) if cb else raise "invalid radio button/group value" end end |