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

cast_from cast_to inheritor meta_class metaclass null? restore_snapshot super_at superior take_snapshot to_b to_bool to_json to_xoxo val? with_accessor with_reader with_writer yaml

### Included Modules

Facets::Automatic AutoVivify

### Public Instance methods

cast_from(object)

Cast on object from another

      String.cast_from(1234) => "1234"

cast_to(klass)

Cast an object to another

       1234.cast_to(String)  => "1234"

inheritor( key, obj, op=nil )

Create an inheritor "class attribute".

meta_class(&block)

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

metaclass(&block)

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

null?()
restore_snapshot(snap)
super_at(klass=self.class.superclass, *args, &blk)

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

take_snapshot()
to_b()

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

to_bool()
to_json(*)

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

to_xoxo(*args)

Dump object as XOXO.

val?()

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.

with_accessor(h)

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

with_reader(h)

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

with_writer(h)

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

yaml(*args,&blk)

[Validate]