Revision f9971af0
Added by Marc Dequènes over 14 years ago
- ID f9971af052b7e206b35f7ea486ed7f346be020eb
lib/cyborghood/base/lang_additions.rb | ||
---|---|---|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||
#++
|
||
|
||
require 'active_support'
|
||
require 'ostruct'
|
||
|
||
class Hash
|
||
... | ... | |
def human_name
|
||
self.class.human_name
|
||
end
|
||
|
||
def singleton_class
|
||
class << self; self; end
|
||
end
|
||
end
|
||
|
||
class String
|
lib/cyborghood/cyborg/interface.rb | ||
---|---|---|
end
|
||
|
||
module CyborgServerInterfaceBase
|
||
NODE_PATTERN = "([a-zA-Z0-9._]+(?:\/[a-zA-Z0-9._]+)*[?=]?)"
|
||
NODE_PATTERN = "(\/(?:\/[a-zA-Z0-9._]+)*[?=]?)"
|
||
|
||
def self.included(base)
|
||
base.extend(ClassMethods)
|
||
... | ... | |
def find_node_action(node_name)
|
||
next_node_name, other_nodes_names = node_name.split('/', 2)
|
||
|
||
next_node_klass = api_klasses[next_node_name]
|
||
next_node_klass = (node_name == "/") ? self.class : api_klasses[next_node_name]
|
||
# inner class or method ?
|
||
if next_node_klass.nil?
|
||
# method is declared ?
|
||
if api_methods.include? next_node_name
|
||
# final node ?
|
||
if other_nodes_names.nil?
|
||
if other_nodes_names.blank?
|
||
# cannot use method(), as this method may not exist at all (but still
|
||
# be usuable through metaprogramming
|
||
return lambda do |*args|
|
||
... | ... | |
else
|
||
next_node = next_node_klass.instance
|
||
# final node ?
|
||
return next_node.method('api_nodes') if other_nodes_names.nil?
|
||
return next_node.method('api_nodes') if other_nodes_names.blank?
|
||
end
|
||
|
||
# search deeper
|
Also available in: Unified diff
[evol] work on cyborg server protocol and API #8 (refs #31)