module FirestoreODM

Attributes

conversions[R]
options[R]

Public Instance Methods

add_conversion(type, target) click to toggle source

Sets a conversion rule for a certain type. @param type [Class] @param target [Symbol, Proc]

# File lib/firestore-odm.rb, line 36
def add_conversion type, target
  @conversions[type] = target
  return
end
add_option(name, &block) click to toggle source

@param name [Symbol]

# File lib/firestore-odm.rb, line 56
def add_option name, &block
  @options[name] = block
end
get_conversion(type) click to toggle source

Gets a conversion. @param type [Class] @return [Proc]

# File lib/firestore-odm.rb, line 44
def get_conversion type
  case rule = conversions[type]
  when Symbol
    Proc.new { |value| value.method(rule).call }
  when Proc
    rule
  else
    raise "Conversion not found for type `#{type}`"
  end
end
get_option(name, option) click to toggle source
# File lib/firestore-odm.rb, line 60
def get_option name, option
  method = @options[name]

  case option
  when Proc
    get_option name, option.call
  else
    method.call option
  end
end