Class: YAS::SymbolizeExt

Inherits:
Object
  • Object
show all
Defined in:
lib/yas/ext/symbolize.rb

Overview

Symbolize keys

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Class Method Details

.apply(schema, hash) ⇒ Object



25
26
27
28
29
# File 'lib/yas/ext/symbolize.rb', line 25

def self.apply schema, hash
  hash.keys.each do |key|
    hash[(key.to_sym rescue key) || key] = hash.delete(key)
  end if schema.symbolize
end

.when_schema_inherited(superschema, subschema) ⇒ Object



20
21
22
# File 'lib/yas/ext/symbolize.rb', line 20

def self.when_schema_inherited superschema, subschema
  subschema.symbolize(superschema.symbolize)
end

.when_used(schema) ⇒ Object



15
16
17
# File 'lib/yas/ext/symbolize.rb', line 15

def self.when_used schema
  schema.extend ClassMethods
end