Class: Compositor::Leaf

Inherits:
Base
  • Object
show all
Defined in:
lib/compositor/leaf.rb

Direct Known Subclasses

LiteralCompositor

Instance Attribute Summary

Attributes inherited from Base

#attrs, #context

Instance Method Summary collapse

Methods inherited from Base

#include_root?, inherited, #initialize, original_dsl_name, #to_h, #to_hash, #to_json, #with_root_element

Constructor Details

This class inherits a constructor from Compositor::Base

Instance Method Details

#composite?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/compositor/leaf.rb', line 14

def composite?
  false
end

#dsl(dsl) ⇒ Object



18
19
20
21
22
23
24
25
# File 'lib/compositor/leaf.rb', line 18

def dsl(dsl)
  if dsl.generator
    raise "Leaves should be called within composite" unless dsl.generator.composite?
    dsl.generator.collection << self
  else
    dsl.generator = self
  end
end

#rootObject



4
5
6
7
8
9
10
11
12
# File 'lib/compositor/leaf.rb', line 4

def root
  if @root.is_a?(Symbol)
    super
  elsif @root
    self.class.original_dsl_name.to_sym
  else
    nil
  end
end