Module: Loba::Internal
- Defined in:
- lib/loba.rb
Defined Under Namespace
Classes: Deprecated, Platform, TimeKeeper
Class Method Summary collapse
-
.calling_class_name(depth = 0) ⇒ Object
Prepare display of class name from where Loba was invoked.
-
.calling_line_number(depth = 0) ⇒ Object
Prepare display of line number from where Loba was invoked [UNUSED].
-
.calling_method_name(depth = 0) ⇒ Object
Prepare display of method name from where Loba was invoked.
-
.calling_method_type(depth = 0) ⇒ Object
Prepare display of whether the method from where Loba was invoked is for a class or an instance.
-
.calling_source_line(depth = 0) ⇒ Object
Identify source code line from where Loba was invoked.
-
.calling_tag(depth = 0) ⇒ Object
Assemble display that shows the method invoking Loba.
-
.filter_options(options, allowed_keys = []) ⇒ Object
Filters options argument for deprecated or unexpected use.
Class Method Details
.calling_class_name(depth = 0) ⇒ Object
Prepare display of class name from where Loba was invoked
147 148 149 150 151 152 153 154 155 156 |
# File 'lib/loba.rb', line 147 def calling_class_name(depth = 0) m = binding.of_caller(depth+1).eval('self.class.name') if m.nil? || m.empty? '<anonymous class>' elsif m == 'Class' binding.of_caller(depth+1).eval('self.name') else m end end |
.calling_line_number(depth = 0) ⇒ Object
Prepare display of line number from where Loba was invoked [UNUSED]
177 178 179 |
# File 'lib/loba.rb', line 177 def calling_line_number(depth = 0) binding.of_caller(depth+1).eval('__LINE__') end |
.calling_method_name(depth = 0) ⇒ Object
Prepare display of method name from where Loba was invoked
160 161 162 163 |
# File 'lib/loba.rb', line 160 def calling_method_name(depth = 0) m = binding.of_caller(depth+1).eval('self.send(:__method__)') (m.nil? || m.empty?) ? '<anonymous method>' : m end |
.calling_method_type(depth = 0) ⇒ Object
Prepare display of whether the method from where Loba was invoked is for a class or an instance
167 168 169 170 171 172 173 |
# File 'lib/loba.rb', line 167 def calling_method_type(depth = 0) if binding.of_caller(depth+1).eval('self.class.name') == 'Class' :class else :instance end end |
.calling_source_line(depth = 0) ⇒ Object
Identify source code line from where Loba was invoked
190 191 192 |
# File 'lib/loba.rb', line 190 def calling_source_line(depth = 0) caller[depth] end |
.calling_tag(depth = 0) ⇒ Object
Assemble display that shows the method invoking Loba
183 184 185 186 |
# File 'lib/loba.rb', line 183 def calling_tag(depth = 0) delim = {class: '.', instance: '#'} "[#{calling_class_name(depth+1)}#{delim[calling_method_type(depth+1)]}#{calling_method_name(depth+1)}]" end |
.filter_options(options, allowed_keys = []) ⇒ Object
Filters options argument for deprecated or unexpected use
197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 |
# File 'lib/loba.rb', line 197 def (, allowed_keys = []) result = {} allowed_keys.each { |key| result[key] = false } case when Hash allowed_keys.each do |key| result[key] = !![key] unless [key].nil? end when TrueClass if allowed_keys.include? :production Internal::Deprecated._0_3_0(true) result[:production] = true end when FalseClass Internal::Deprecated._0_3_0(false) else # to be safe, treat as false Internal::Deprecated._0_3_0(false) end result end |