Class: Lowkey::FileProxy
- Includes:
- Query
- Defined in:
- lib/proxies/file_proxy.rb
Instance Attribute Summary collapse
-
#definitions ⇒ Object
Returns the value of attribute definitions.
-
#dependencies ⇒ Object
Returns the value of attribute dependencies.
-
#root_node ⇒ Object
readonly
Returns the value of attribute root_node.
Attributes inherited from Proxy
Instance Method Summary collapse
- #[](keypath) ⇒ Object
- #[]=(keypath, value) ⇒ Object
-
#initialize(root_node:, source:) ⇒ FileProxy
constructor
A new instance of FileProxy.
- #upsert_definition(module_proxy:) ⇒ Object
- #upsert_dependency(namespace:) ⇒ Object
Methods included from Query
Constructor Details
#initialize(root_node:, source:) ⇒ FileProxy
Returns a new instance of FileProxy.
14 15 16 17 18 19 20 21 |
# File 'lib/proxies/file_proxy.rb', line 14 def initialize(root_node:, source:) super(name: nil, source:) @root_node = root_node @definitions = {} @dependencies = Set.new end |
Instance Attribute Details
#definitions ⇒ Object
Returns the value of attribute definitions.
12 13 14 |
# File 'lib/proxies/file_proxy.rb', line 12 def definitions @definitions end |
#dependencies ⇒ Object
Returns the value of attribute dependencies.
12 13 14 |
# File 'lib/proxies/file_proxy.rb', line 12 def dependencies @dependencies end |
#root_node ⇒ Object (readonly)
Returns the value of attribute root_node.
11 12 13 |
# File 'lib/proxies/file_proxy.rb', line 11 def root_node @root_node end |
Instance Method Details
#[](keypath) ⇒ Object
23 24 25 26 |
# File 'lib/proxies/file_proxy.rb', line 23 def [](keypath) namespace, *file_path = keypath.split('.') file_path.empty? ? @definitions[namespace] : query(node: @root_node, namespace:, name: file_path.join) end |
#[]=(keypath, value) ⇒ Object
28 29 30 |
# File 'lib/proxies/file_proxy.rb', line 28 def []=(keypath, value) # TODO: Slice the lines in a file and replace with the output of the class proxy. end |
#upsert_definition(module_proxy:) ⇒ Object
32 33 34 35 |
# File 'lib/proxies/file_proxy.rb', line 32 def upsert_definition(module_proxy:) # TODO: Merge duplicate class with existing class. @definitions[module_proxy.namespace] ||= module_proxy end |
#upsert_dependency(namespace:) ⇒ Object
37 38 39 |
# File 'lib/proxies/file_proxy.rb', line 37 def upsert_dependency(namespace:) @dependencies.add(namespace) end |