Method: OpenGraphReader::Object::DSL#integer

Defined in:
lib/open_graph_reader/object/dsl/types.rb

#integer(name, options = {}) ⇒ Object

Parameters:

  • name (Symbol)

    the name of the property in the current namespace

  • options ({Symbol => Bool, Class, Array<String>}) (defaults to: {})

    additional options

Options Hash (options):

  • :required (Bool) — default: false

    Make the property required.

  • :collection (Bool) — default: false

    This property can occur multiple times.

  • :to (Class)

    This property maps to the given object (optional). belongs to the given verticals of the object (optional).

  • :verticials (Array<String>)

    This property

  • :downcase (Bool) — default: false

    Normalize the contents case to lowercase.



70
71
72
73
74
75
76
77
# File 'lib/open_graph_reader/object/dsl/types.rb', line 70

define_type :integer do  |value, options|
  begin
    Integer(value)
  rescue ArgumentError
    next unless options[:required] || !OpenGraphReader.config.discard_invalid_optional_properties
    raise InvalidObjectError, "Integer expected, but was #{value.inspect}"
  end
end