Class: Restspec::Schema::Types::DecimalType

Inherits:
BasicType
  • Object
show all
Defined in:
lib/restspec/schema/types/decimal_type.rb

Direct Known Subclasses

DecimalStringType

Instance Method Summary collapse

Methods inherited from BasicType

#initialize, #of, #totally_valid?, #|

Constructor Details

This class inherits a constructor from Restspec::Schema::Types::BasicType

Instance Method Details

#example_for(attribute) ⇒ Object



3
4
5
6
7
8
# File 'lib/restspec/schema/types/decimal_type.rb', line 3

def example_for(attribute)
  integer_part = example_options.fetch(:integer_part, 2)
  decimal_part = example_options.fetch(:decimal_part, 2)

  Faker::Number.decimal(integer_part, decimal_part)
end

#valid?(attribute, value) ⇒ Boolean

Returns:

  • (Boolean)


10
11
12
# File 'lib/restspec/schema/types/decimal_type.rb', line 10

def valid?(attribute, value)
  value.is_a?(Numeric)
end