Class: Flexite::CachedNode

Inherits:
SimpleDelegator
  • Object
show all
Defined in:
lib/flexite/cached_node.rb

Instance Method Summary collapse

Constructor Details

#initialize(node) ⇒ CachedNode

Returns a new instance of CachedNode.



3
4
5
6
7
8
9
# File 'lib/flexite/cached_node.rb', line 3

def initialize(node)
  super(node.configs.each_with_object(NodesHash.new) do |sub_node, memo|
    memo[sub_node.name] = Flexite.cache.fetch(sub_node) do
      sub_node.selectable? ? sub_node.value : CachedNode.new(sub_node)
    end
  end)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args, &block) ⇒ Object



15
16
17
# File 'lib/flexite/cached_node.rb', line 15

def method_missing(name, *args, &block)
  __getobj__.send(name, *args, &block)
end

Instance Method Details

#is_a?(klass) ⇒ Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/flexite/cached_node.rb', line 11

def is_a?(klass)
  __getobj__.is_a?(klass)
end