Class: Cuca::Generator::View::AssignBindings
- Inherits:
-
Object
- Object
- Cuca::Generator::View::AssignBindings
- Defined in:
- lib/cuca/generator/view.rb
Overview
:nodoc:
Instance Method Summary collapse
- #get_bindings ⇒ Object
-
#initialize(assigns, base_object) ⇒ AssignBindings
constructor
A new instance of AssignBindings.
- #method_missing(sym, *args, &block) ⇒ Object
Constructor Details
#initialize(assigns, base_object) ⇒ AssignBindings
Returns a new instance of AssignBindings.
48 49 50 51 52 53 |
# File 'lib/cuca/generator/view.rb', line 48 def initialize(assigns, base_object) assigns.each_pair do |k,v| instance_variable_set("@#{k}", v) end @base = base_object end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(sym, *args, &block) ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/cuca/generator/view.rb', line 55 def method_missing(sym, *args, &block ) class_name = sym.id2name # 1st try to find method in the base widget if @base.methods.include?(class_name) then return @base.send(class_name, *args, &block) end c = nil # 2nd try to find a widget if Object.const_defined?(class_name+'Widget') then c = Object::const_get(class_name+'Widget') else # ...try to find in action namespace mod = $app.urlmap.action_module c = mod.const_get(class_name+'Widget') if mod.const_defined?(class_name+'Widget') end raise NameError.new "Undefined method: #{class_name}" unless c = c.new({:args => args, :assigns => @assigns }, &block) # $stderr.puts "Widget:" + widget.inspect return .to_s # $stderr.puts "Good" end |
Instance Method Details
#get_bindings ⇒ Object
44 45 46 |
# File 'lib/cuca/generator/view.rb', line 44 def get_bindings binding end |