module Persistent💎
frozen_string_literal: true
frozen_string_literal: true
frozen_string_literal: true
frozen_string_literal: true
Constants
- VERSION
Public Class Methods
# 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
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
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
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
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
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