Module: Musashi::Retriever::VisitorStrategist
Instance Attribute Summary
Attributes included from Connection
#endpoint, #format
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Strategist
define, #define, define_by_behavior, define_by_name, #follow?, #no_follow, retrievers_by_behavior, retrievers_by_behavior=, retrievers_by_name, retrievers_by_name=
Methods included from Base
#retrieve, #retrieved?
Methods included from Connection
#accept, #connection, #options
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(sym, *args, &block) ⇒ Object
117
118
119
120
121
122
123
124
125
126
|
# File 'lib/musashi/retriever.rb', line 117
def method_missing(sym,*args,&block)
super unless args.empty?
super unless has_key?(sym)
value = self.fetch(sym.to_s) rescue self.fetch(sym) rescue nil
return value if value.nil?
define value, sym if follow?(sym)
value
end
|
Class Method Details
.extend?(receiver) ⇒ Boolean
90
91
92
93
|
# File 'lib/musashi/retriever.rb', line 90
def self.extend?(receiver)
!receiver.nil? && receiver.respond_to?(:keys) && \
receiver.respond_to?(:fetch) && !receiver.is_a?(VisitorStrategist)
end
|
.extend_object(receiver) ⇒ Object
95
96
97
98
99
|
# File 'lib/musashi/retriever.rb', line 95
def self.extend_object(receiver)
return if receiver.is_a?(VisitorStrategist)
raise RuntimeError.new unless VisitorStrategist.extend? receiver
super
end
|
Instance Method Details
#[](key) ⇒ Object
101
102
103
104
105
106
107
|
# File 'lib/musashi/retriever.rb', line 101
def [](key)
return nil unless self.has_key?(key)
value = self.fetch(key.to_s) rescue self.fetch(key) rescue nil
return value if value.nil?
define value,key.to_sym if follow?(key)
value
end
|
#has_key?(key) ⇒ Boolean
109
110
111
|
# File 'lib/musashi/retriever.rb', line 109
def has_key?(key)
self.key?(key.to_s) || self.key?(key)
end
|
#respond_to?(method) ⇒ Boolean
113
114
115
|
# File 'lib/musashi/retriever.rb', line 113
def respond_to?(method)
self.has_key?(method) ? true : super
end
|