Class: EntitySchema::Fields::Specifications::Abstract
- Inherits:
-
Object
- Object
- EntitySchema::Fields::Specifications::Abstract
show all
- Defined in:
- lib/entity_schema/specifications/abstract.rb
Overview
Transform raw valid options to usefull options
Instance Method Summary
collapse
Constructor Details
#initialize(name, owner_name, raw_options) ⇒ Abstract
Returns a new instance of Abstract.
8
9
10
11
12
|
# File 'lib/entity_schema/specifications/abstract.rb', line 8
def initialize(name, owner_name, raw_options)
@options = transform_options(name: name,
owner_name: owner_name,
**raw_options)
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(key, *_args, **_opts) ⇒ Object
22
23
24
25
26
27
|
# File 'lib/entity_schema/specifications/abstract.rb', line 22
def method_missing(key, *_args, **_opts)
return options[key] if options.key?(key)
root = without_predicate(key)
return options[root] if bool_key?(root)
super
end
|
Instance Method Details
14
15
16
|
# File 'lib/entity_schema/specifications/abstract.rb', line 14
def [](key)
options.fetch(key, nil)
end
|
#respond_to_missing?(key) ⇒ Boolean
29
30
31
|
# File 'lib/entity_schema/specifications/abstract.rb', line 29
def respond_to_missing?(key)
options.key?(key) || bool_key?(without_predicate(key))
end
|
18
19
20
|
# File 'lib/entity_schema/specifications/abstract.rb', line 18
def to_h
options.dup
end
|