Class Object
In: lib/facets/automatic.rb
lib/facets/more/methodfilter.rb
lib/facets/more/typecast.rb
lib/facets/more/xoxo.rb
lib/facets/more/basicobject.rb
lib/facets/more/json.rb
lib/facets/more/inheritor.rb
lib/facets/more/snapshot.rb
lib/facets/more/nullclass.rb
lib/facets/more/autovivify.rb
lib/facets/core/kernel/to_b.rb
lib/facets/core/kernel/with_accessor.rb
lib/facets/core/kernel/to_bool.rb
lib/facets/core/kernel/val.rb
lib/facets/core/kernel/super_at.rb
lib/facets/core/kernel/metaclass.rb
lib/facets/core/kernel/yaml.rb
lib/facets/core/kernel/meta_class.rb
Parent: Object

Methods

Included Modules

Facets::Automatic AutoVivify

Public Instance methods

Cast on object from another

  String.cast_from(1234) => "1234"

Cast an object to another

   1234.cast_to(String)  => "1234"

Create an inheritor "class attribute".

Easy access to an object‘s "special" class, otherwise known as it‘s metaclass or singleton class.

Easy access to an object‘s "special" class, otherwise known as it‘s metaclass or singleton class.

Like super but skips to a specific ancestor module or class.

  class A
    def x ; 1 ; end
  end

  class B < A
    def x ; 2 ; end
  end

  class C < B
    def x ; superior(A) ; end
  end

  C.new.x  #=> 1
superior(klass=self.class.superclass, *args, &blk)

Alias for super_at

Boolean conversion for not being nil or false. Other classes may redefine this to suite the particular need.

  "abc".to_b   #=> true
  true.to_b    #=> true
  false.to_b   #=> false
  nil.to_b     #=> false

Fallback to_json method uses to_yaml, strips the type header and then reloads as a pure hash, which is then converted to JSON.

Dump object as XOXO.

Tests to see if something has value. An object is considered to have value if it is not nil? and if it responds to empty?, i snot.

Takes a hash and creates (singleton) attr_accessors for each key.

  with_accessor { :x => 1, :y => 2 }
  @x          #=> 1
  @y          #=> 2
  self.x = 3
  self.y = 4
  self.x      #=> 3
  self.y      #=> 4

Takes a hash and creates (singleton) attr_readers for each key.

  with_reader { :x => 1, :y => 2 }
  @x       #=> 1
  @y       #=> 2
  self.x   #=> 1
  self.y   #=> 2

Takes a hash and creates (singleton) attr_writers for each key.

  with_writer { :x => 1, :y => 2 }
  @x           #=> 1
  @y           #=> 2
  self.x = 3
  self.y = 4
  @x           #=> 3
  @y           #=> 4

[Validate]