Class Object
In: lib/ext/object.rb
lib/ext/metaclass.rb
lib/inactive_support/core_ext/blank.rb
Parent: Object

Methods

Public Class methods

Lists methods unique to a class.

[Source]

# File lib/ext/object.rb, line 8
  def self.unique_methods
    (public_methods - Object.methods).sort.map(&:to_sym)
  end

Public Instance methods

Returns a list of arguments and an options hash. Source taken from RSpec.

[Source]

# File lib/ext/object.rb, line 13
  def args_and_opts(*args)
    options = Hash === args.last ? args.pop : {}
    return args, options
  end

An object is blank if it‘s nil, empty, or a whitespace string. For example, "", " ", nil, [], and {} are blank.

This simplifies

  if !address.nil? && !address.empty?

to

  if !address.blank?

[Source]

# File lib/inactive_support/core_ext/blank.rb, line 9
  def blank?
    respond_to?(:empty?) ? empty? : !self
  end

Defines an instance method within a class

[Source]

# File lib/ext/metaclass.rb, line 14
  def class_def name, &blk
    class_eval { define_method name, &blk }
  end

Adds methods to a metaclass

[Source]

# File lib/ext/metaclass.rb, line 9
  def meta_def name, &blk
    meta_eval { define_method name, &blk }
  end

[Source]

# File lib/ext/metaclass.rb, line 6
  def meta_eval(&blk); metaclass.instance_eval(&blk); end

The hidden singleton lurks behind everyone

[Source]

# File lib/ext/metaclass.rb, line 5
  def metaclass; class << self; self; end; end

Lists methods unique to an instance.

[Source]

# File lib/ext/object.rb, line 3
  def unique_methods
    (public_methods - Object.methods).sort.map(&:to_sym)
  end

[Validate]