Module: Vk::Schema::Definition::HasAttributes
Instance Method Summary collapse
- #attributes ⇒ <Attribute>
- #properties ⇒ Hash{String => Hash}
- #required_attribute?(attribute) ⇒ Boolean
Instance Method Details
#attributes ⇒ <Attribute>
9 10 11 12 13 |
# File 'lib/vk/schema/definition/has_attributes.rb', line 9 def attributes @attributes ||= properties.map do |name, definition| Attribute.new(name, definition, schema, self) end end |
#properties ⇒ Hash{String => Hash}
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/vk/schema/definition/has_attributes.rb', line 16 def properties if definition['properties'] definition['properties'] elsif definition['allOf'].is_a?(Array) definition['allOf'].each_with_object({}) do |definition, memo| memo.merge!(definition['properties'] || {}) end elsif definition['parameters'].is_a?(Array) definition['parameters'].each_with_object({}) do |parameter, memo| memo[parameter['name']] = parameter end else {} end end |
#required_attribute?(attribute) ⇒ Boolean
34 35 36 37 |
# File 'lib/vk/schema/definition/has_attributes.rb', line 34 def required_attribute?(attribute) return false unless definition.key?('required') definition['required'].include?(attribute.to_s) end |