Class: Dacs::PermissiveSchema
- Inherits:
-
Object
- Object
- Dacs::PermissiveSchema
- Defined in:
- lib/dacs/permissive_schema.rb
Instance Method Summary collapse
- #default_value(key) ⇒ Object
- #defaults ⇒ Object
- #defined?(key) ⇒ Boolean
-
#initialize(defaults = {}) ⇒ PermissiveSchema
constructor
A new instance of PermissiveSchema.
- #keys ⇒ Object
- #optional?(key) ⇒ Boolean
- #required?(key) ⇒ Boolean
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 |
#defaults ⇒ Object
30 31 32 |
# File 'lib/dacs/permissive_schema.rb', line 30 def defaults @defaults end |
#defined?(key) ⇒ Boolean
22 23 24 |
# File 'lib/dacs/permissive_schema.rb', line 22 def defined?(key) true end |
#keys ⇒ Object
10 11 12 |
# File 'lib/dacs/permissive_schema.rb', line 10 def keys @defaults.keys end |
#optional?(key) ⇒ Boolean
14 15 16 |
# File 'lib/dacs/permissive_schema.rb', line 14 def optional?(key) true end |
#required?(key) ⇒ Boolean
18 19 20 |
# File 'lib/dacs/permissive_schema.rb', line 18 def required?(key) false end |