class Dynamoid::Undumping::SetUndumper
Constants
- ALLOWED_TYPES
Public Instance Methods
process(set)
click to toggle source
# File lib/dynamoid/undumping.rb, line 105 def process(set) if @options.key?(:of) process_typed_collection(set) else set.is_a?(Set) ? set : Set.new(set) end end
Private Instance Methods
allowed_type?()
click to toggle source
# File lib/dynamoid/undumping.rb, line 124 def allowed_type? ALLOWED_TYPES.include?(element_type) || element_type.is_a?(Class) end
element_options()
click to toggle source
# File lib/dynamoid/undumping.rb, line 136 def element_options if @options[:of].is_a?(Hash) @options[:of][element_type].dup.tap do |options| options[:type] = element_type end else { type: element_type } end end
element_type()
click to toggle source
# File lib/dynamoid/undumping.rb, line 128 def element_type if @options[:of].is_a?(Hash) @options[:of].keys.first else @options[:of] end end
process_typed_collection(set)
click to toggle source
# File lib/dynamoid/undumping.rb, line 115 def process_typed_collection(set) if allowed_type? undumper = Undumping.find_undumper(element_options) set.map { |el| undumper.process(el) }.to_set else raise ArgumentError, "Set element type #{element_type} isn't supported" end end