Class: Hamster::SortedSet
- Defined in:
- lib/nrser/gem_ext/hamster/sorted_set.rb
Overview
Definitions
Direct Known Subclasses
Instance Method Summary collapse
- #as_json(options = nil) ⇒ Object
- #to_h ⇒ Object
-
#to_mutable ⇒ Object
Instance Methods ========================================================================.
- #to_mutable_array ⇒ Object
- #to_yaml(*args, &block) ⇒ Object
Instance Method Details
#as_json(options = nil) ⇒ Object
53 54 55 56 |
# File 'lib/nrser/gem_ext/hamster/sorted_set.rb', line 53 def as_json = nil to_mutable_array.to_json # { '$set' => to_h.as_json( options ) } end |
#to_h ⇒ Object
48 49 50 |
# File 'lib/nrser/gem_ext/hamster/sorted_set.rb', line 48 def to_h each_with_object( {} ) { |member, hash| hash[member] = true } end |
#to_mutable ⇒ Object
Instance Methods
34 35 36 37 38 |
# File 'lib/nrser/gem_ext/hamster/sorted_set.rb', line 34 def to_mutable each_with_object( ::SortedSet[] ) { |member, set| set << Hamster.to_mutable( member ) } end |
#to_mutable_array ⇒ Object
41 42 43 44 45 |
# File 'lib/nrser/gem_ext/hamster/sorted_set.rb', line 41 def to_mutable_array each_with_object( [] ) { |member, array| array << Hamster.to_mutable( member ) } end |
#to_yaml(*args, &block) ⇒ Object
59 60 61 |
# File 'lib/nrser/gem_ext/hamster/sorted_set.rb', line 59 def to_yaml *args, &block to_mutable.to_yaml *args, &block end |