Class: Object
- Inherits:
- BasicObject
- Defined in:
- lib/droiuby/support/object.rb,
lib/droiuby/support/thread.rb,
lib/droiuby/support/autoload.rb,
lib/droiuby/support/to_query.rb
Class Method Summary collapse
Instance Method Summary collapse
- #blank? ⇒ Boolean
- #boolean? ⇒ Boolean
-
#to_query(key) ⇒ Object
Converts an object into a string suitable for use as a URL query string, using the given
keyas the param name. - #with_large_stack(stack_size_kb = 64, &block) ⇒ Object
Class Method Details
.const_missing(name) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/droiuby/support/autoload.rb', line 5 def const_missing(name) puts "constant missing #{name}" @looked_for ||= {} str_name = name.to_s raise "Class not found: #{name}" if @looked_for[str_name] @looked_for[str_name] = 1 name_parts = name.to_s.split('::').collect { |n| n.underscore } require_path = File.join(*name_parts) puts "autoloading #{require_path}" require require_path klass = const_get(name) return klass if klass raise "Class not found: #{name}" end |
.const_missing_old ⇒ Object
4 |
# File 'lib/droiuby/support/autoload.rb', line 4 alias :const_missing_old :const_missing |
Instance Method Details
#blank? ⇒ Boolean
3 4 5 |
# File 'lib/droiuby/support/object.rb', line 3 def blank? respond_to?(:empty?) ? empty? : !self end |
#boolean? ⇒ Boolean
7 8 9 |
# File 'lib/droiuby/support/object.rb', line 7 def boolean? self.is_a?(TrueClass) || self.is_a?(FalseClass) end |
#to_query(key) ⇒ Object
Converts an object into a string suitable for use as a URL query string, using the given key as the param name.
Note: This method is defined as a default implementation for all Objects for Hash#to_query to work.
8 9 10 11 |
# File 'lib/droiuby/support/to_query.rb', line 8 def to_query(key) require 'cgi' unless defined?(CGI) && defined?(CGI::escape) "#{CGI.escape(key.to_param)}=#{CGI.escape(to_param.to_s)}" end |
#with_large_stack(stack_size_kb = 64, &block) ⇒ Object
2 3 4 5 6 7 |
# File 'lib/droiuby/support/thread.rb', line 2 def with_large_stack(stack_size_kb = 64, &block) result = nil t = Thread.with_large_stack(&proc{result = block.call}) t.join result end |