class Render::Attribute

Constants

SCHEMA_IDENTIFIERS

Attributes

default[W]
enums[RW]
exclusive_maximum[RW]
exclusive_minimum[RW]
format[RW]
max_length[RW]
maximum[RW]
min_length[RW]
minimum[RW]
multiple_of[RW]
name[RW]
schema[RW]
types[RW]

Public Class Methods

new(options = {}) click to toggle source
# File lib/render/attributes/attribute.rb, line 22
def initialize(options = {})
  Render.logger.debug("Initializing attribute #{options}")
end

Public Instance Methods

bias_type() click to toggle source
# File lib/render/attributes/attribute.rb, line 26
def bias_type
  format || types.first
end
default_value() click to toggle source
# File lib/render/attributes/attribute.rb, line 30
def default_value
  @default || (Render.live ? nil : faux_value)
end
nested_schema?(options = {}) click to toggle source
# File lib/render/attributes/attribute.rb, line 34
def nested_schema?(options = {})
  options.any? { |name, value| SCHEMA_IDENTIFIERS.include?(name) }
end

Private Instance Methods

faux_value() click to toggle source
# File lib/render/attributes/attribute.rb, line 59
def faux_value
  Generator.trigger(bias_type, name, self)
end
process_options!(options) click to toggle source
# File lib/render/attributes/attribute.rb, line 40
def process_options!(options)
  self.types = [Type.parse!(options[:type])].flatten
  self.format = Type.parse(options[:format])

  if (options[:enum])
    self.enums = options[:enum]
    self.types = [Type::Enum]
  end

  @default = options[:default]
  self.min_length = options[:minLength]
  self.max_length = options[:maxLength]
  self.multiple_of = options[:multipleOf]
  self.minimum = options[:minimum]
  self.maximum = options[:maximum]
  self.exclusive_minimum = !!options[:exclusiveMinimum]
  self.exclusive_maximum = !!options[:exclusiveMaximum]
end