Module: Ferris::SiteObject
- Defined in:
- lib/ferris/core.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *arg, &blk) ⇒ Object
143
144
145
146
|
# File 'lib/ferris/core.rb', line 143
def method_missing(name, *arg, &blk)
@@defined_classes.each {|class_name| return class_name.new.send(name, *arg, &blk) if class_name.new.respond_to?(name) }
super
end
|
Class Method Details
127
128
129
130
131
132
133
|
# File 'lib/ferris/core.rb', line 127
def self.configure(&blk)
raise 'Must provide block with defined regions' unless block_given?
last_defined_class = defined_classes.last
last_defined_class.include Browser
last_defined_class.extend Region
last_defined_class.instance_exec(&blk)
end
|
.defined_classes ⇒ Object
135
136
137
|
# File 'lib/ferris/core.rb', line 135
def self.defined_classes
self.constants.select {|k| self.const_get(k).is_a? Class }.map {|class_name| Object.const_get("#{self.to_s}::#{class_name.to_s}") }
end
|
.included(_kls) ⇒ Object
139
140
141
|
# File 'lib/ferris/core.rb', line 139
def self.included(_kls)
@@defined_classes = defined_classes
end
|
Instance Method Details
#respond_to_missing?(method_name, _include_private = false) ⇒ Boolean
148
149
150
151
|
# File 'lib/ferris/core.rb', line 148
def respond_to_missing?(method_name, _include_private = false)
@@defined_classes.each {|class_name| return true if class_name.new.respond_to?(method_name)}
super
end
|