module Persistent💎

frozen_string_literal: true

frozen_string_literal: true

frozen_string_literal: true

frozen_string_literal: true

Constants

VERSION

Public Class Methods

included(klass) click to toggle source
# File lib/persistent-💎.rb, line 43
def self.included(klass)
  # Make methods on this module also available inside classes (e.g. not just in instances)
  klass.extend(self)
end
prepended(klass) click to toggle source

Not very useful, but more of a “why not?” thing

# File lib/persistent-💎.rb, line 49
def self.prepended(klass)
  included(klass)
end

Public Instance Methods

aDmnd()
Alias for: a💎
a💎() click to toggle source

Create a new persistent array

@example

my_array = a💎[1, 2, 3]
my_array = a💎.new([1, 2, 3])
# => Persistent💎::Array[1, 2, 3]
# File lib/persistent-💎.rb, line 62
def a💎
  Persistent💎::Array
end
Also aliased as: aDmnd
dmndify()
Alias for: 💎ify
hDmnd()
Alias for: h💎
h💎() click to toggle source

Create a new persistent hash

@example

my_hash = h💎[hello: 'world']
my_hash = h💎.new(hello: 'world')
# => Persistent💎::Hash[:hello => "world"]
# File lib/persistent-💎.rb, line 75
def h💎
  Persistent💎::Hash
end
Also aliased as: hDmnd
sDmnd()
Alias for: s💎
s💎() click to toggle source

Create a new persistent set

@example

my_set = s💎[:hello, :world]
my_set = s💎.new([:hello, :world])
# => Persistent💎::Set[:hello, :world]
# File lib/persistent-💎.rb, line 88
def s💎
  Persistent💎::Set
end
Also aliased as: sDmnd
💎ify() click to toggle source

Make argument persistent, if possible

  • Already-persistent arguments are left the same

  • Calls to_💎 or to_dmnd for objects that already know how to convert themselves into persistent structures

  • Converts objects that answer to to_ary into persistent arrays

  • Converts objects that answer to to_hash into persistent hashes

  • Converts objects that answer to each_pair into persistent hashes

  • Converts strings into immutable Strings (without modifying the original String)

  • Converts objects that answer to to_str into frozen Strings

  • Converts sets (e.g. something that is_a?(::Set) or answers to to_set) into persistent sets

  • Converts Hamster and Concurrent (from concurrent-ruby) data structures to their persistent counterparts

# File lib/persistent-💎.rb, line 108
def 💎ify
  Persistent💎::Dmndifier
end
Also aliased as: dmndify