Class: Render::Attribute

Inherits:
Object
  • Object
show all
Defined in:
lib/render/attribute.rb

Direct Known Subclasses

ArrayAttribute, HashAttribute

Constant Summary collapse

SCHEMA_IDENTIFIERS =
[:properties, :items].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Attribute

Returns a new instance of Attribute.



17
18
19
20
# File 'lib/render/attribute.rb', line 17

def initialize(options = {})
  Render.logger.debug("Initializing attribute #{options}")
  self.required = false
end

Instance Attribute Details

#enumsObject

Returns the value of attribute enums.



10
11
12
# File 'lib/render/attribute.rb', line 10

def enums
  @enums
end

#formatObject

Returns the value of attribute format.



10
11
12
# File 'lib/render/attribute.rb', line 10

def format
  @format
end

#nameObject

Returns the value of attribute name.



10
11
12
# File 'lib/render/attribute.rb', line 10

def name
  @name
end

#requiredObject

Returns the value of attribute required.



10
11
12
# File 'lib/render/attribute.rb', line 10

def required
  @required
end

#schemaObject

Returns the value of attribute schema.



10
11
12
# File 'lib/render/attribute.rb', line 10

def schema
  @schema
end

#typeObject

Returns the value of attribute type.



10
11
12
# File 'lib/render/attribute.rb', line 10

def type
  @type
end

Instance Method Details

#bias_typeObject



22
23
24
# File 'lib/render/attribute.rb', line 22

def bias_type
  format || type
end

#default_valueObject



26
27
28
# File 'lib/render/attribute.rb', line 26

def default_value
  Render.live ? nil : faux_value
end

#nested_schema?(options = {}) ⇒ Boolean

Returns:



30
31
32
# File 'lib/render/attribute.rb', line 30

def nested_schema?(options = {})
  options.any? { |name, value| SCHEMA_IDENTIFIERS.include?(name) }
end