Class: Dacs::PermissiveSchema

Inherits:
Object
  • Object
show all
Defined in:
lib/dacs/permissive_schema.rb

Instance Method Summary collapse

Constructor Details

#initialize(defaults = {}) ⇒ PermissiveSchema

Returns a new instance of PermissiveSchema.



3
4
5
6
7
8
# File 'lib/dacs/permissive_schema.rb', line 3

def initialize(defaults={})
  @defaults = defaults.inject({}) { |h, (k,v)|
    h[k.to_s] = v
    h
  }
end

Instance Method Details

#default_value(key) ⇒ Object



26
27
28
# File 'lib/dacs/permissive_schema.rb', line 26

def default_value(key)
  @defaults[key.to_s]
end

#defaultsObject



30
31
32
# File 'lib/dacs/permissive_schema.rb', line 30

def defaults
  @defaults
end

#defined?(key) ⇒ Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/dacs/permissive_schema.rb', line 22

def defined?(key)
  true
end

#keysObject



10
11
12
# File 'lib/dacs/permissive_schema.rb', line 10

def keys
  @defaults.keys
end

#optional?(key) ⇒ Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/dacs/permissive_schema.rb', line 14

def optional?(key)
  true
end

#required?(key) ⇒ Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/dacs/permissive_schema.rb', line 18

def required?(key)
  false
end