abstract class Object
Overview
Object
is the base type of all Crystal objects.
Defined in:
crystal_on_steroids/dig.crcrystal_on_steroids/object.cr
crystal_on_steroids/to_query.cr
Instance Method Summary
-
#blank?
An object is blank if it's false, empty, or an empty string.
-
#dig?(index, *keys)
Retrieves the value object corresponding to the each key objects repeatedly.
- #dig?
-
#in?(another_object)
Returns true if this object is included in the argument.
-
#presence
Returns the receiver if it's present otherwise returns
nil
. -
#presence_in(another_object)
Returns the receiver if it's included in the argument otherwise returns
nil
. -
#present?
An object is present if it's not blank.
-
#to_param
Alias for
to_s
-
#to_query(key)
Converts an object into a string suitable for use as a URL query string, using the given
key
as the param name. -
#to_query
Converts an object into a string suitable for use as a URL query string, no key provided
Instance Method Detail
An object is blank if it's false, empty, or an empty string.
For example, false
, "", nil
, [], and {} are all blank.
@return [true, false]
source: Rails ActiveSupport
Retrieves the value object corresponding to the each key objects repeatedly. The type needs to implement #[]? method to works.
h = { foo: {bar: {baz: 5}}}
h.dig?(:foo, :bar, :baz) #=> 5
h.dig?(:foo, :blah) #=> nil
Returns true if this object is included in the argument. Argument must be
any object which responds to #include?
. Usage:
characters = ["Konata", "Kagami", "Tsukasa"]
"Konata".in?(characters) # => true
source: Rails ActiveSupport
Returns the receiver if it's present otherwise returns nil
.
object.presence
is equivalent to
object.present? ? object : nil
@return [Object]
source: Rails ActiveSupport
Returns the receiver if it's included in the argument otherwise returns nil
.
Argument must be any object which responds to #include?
. Usage:
params[:bucket_type].presence_in %w( project calendar )
source: Rails ActiveSupport
An object is present if it's not blank.
@return [true, false]
source: Rails ActiveSupport
Converts an object into a string suitable for use as a URL query string,
using the given key
as the param name.
Converts an object into a string suitable for use as a URL query string, no key provided