Class: RubyMVC::Views::PeerView

Inherits:
View show all
Defined in:
lib/ruby_mvc/views/view.rb

Direct Known Subclasses

BrowserView, GridTableView

Instance Attribute Summary collapse

Attributes inherited from View

#controller

Attributes included from ActionProvider

#actions

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ActionProvider

#action

Methods included from Toolkit::SignalHandler::ClassMethods

#signal, #signals, #valid_signal!, #valid_signal?

Methods included from Toolkit::SignalHandler

#signal_emit

Constructor Details

#initialize(options = {}) ⇒ PeerView

Returns a new instance of PeerView.



87
88
89
90
# File 'lib/ruby_mvc/views/view.rb', line 87

def initialize(options = {})
  super
  @widget = PeerView.create_widget(self.class, options)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(m, *a, &b) ⇒ Object



113
114
115
# File 'lib/ruby_mvc/views/view.rb', line 113

def method_missing(m, *a, &b)
  @widget.send(m, *a, &b)
end

Instance Attribute Details

#frameObject

This method is used to retrieve a reference to the parent frame



84
85
86
# File 'lib/ruby_mvc/views/view.rb', line 84

def frame
  @frame
end

#widgetObject

Returns the value of attribute widget.



86
87
88
# File 'lib/ruby_mvc/views/view.rb', line 86

def widget
  @widget
end

Class Method Details

.create_widget(klass, options = {}) ⇒ Object



60
61
62
63
64
65
# File 'lib/ruby_mvc/views/view.rb', line 60

def self.create_widget(klass, options = {})
  w = self.widget_def(klass)
  args = (w[:args].clone << options)
  block = w[:block]
  args[0].new(*args[1..-1], &block)
end

.widget(*args, &block) ⇒ Object

This method is used to define the primary widget class through which this view may be added to other widgets.



72
73
74
75
# File 'lib/ruby_mvc/views/view.rb', line 72

def widget(*args, &block)
#          puts "Set widget for #{self}: #{args.inspect}"
  @widget_def = { :args => args, :block => block }
end

.widget_def(targ = nil) ⇒ Object



46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/ruby_mvc/views/view.rb', line 46

def self.widget_def(targ = nil)
  if targ == nil
    @widget_def
  else
    if (x = targ.widget_def).nil?
      if targ != RubyMVC::Views::PeerView
        self.widget_def(targ.superclass)
      end
    else
      x
    end
  end
end

Instance Method Details

#peerObject



78
79
80
# File 'lib/ruby_mvc/views/view.rb', line 78

def peer
  @widget.peer
end

#signal_connect(signal, &b) ⇒ Object

This method is required to ensure that concrete views appropriately manage signal registration



95
96
97
98
99
100
101
102
103
# File 'lib/ruby_mvc/views/view.rb', line 95

def signal_connect(signal, &b)
#        puts "Widget class: #{@widget.class}"
  if @widget.class.valid_signal? signal
    @widget.signal_connect(signal, &b)
  else
#         puts "super"
    super
  end
end

#signal_disconnect(signal, &b) ⇒ Object



105
106
107
108
109
110
111
# File 'lib/ruby_mvc/views/view.rb', line 105

def signal_disconnect(signal, &b)
  if @widget.class.valid_signal? signal
    @widget.signal_connect(signal, &b)
  else
    super
  end
end