Class: Props::Fragment

Inherits:
Object
  • Object
show all
Defined in:
lib/props_template/extensions/fragment.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(base, fragments = []) ⇒ Fragment

Returns a new instance of Fragment.



5
6
7
8
# File 'lib/props_template/extensions/fragment.rb', line 5

def initialize(base, fragments = [])
  @base = base
  @fragments = fragments
end

Instance Attribute Details

#fragmentsObject (readonly)

Returns the value of attribute fragments.



3
4
5
# File 'lib/props_template/extensions/fragment.rb', line 3

def fragments
  @fragments
end

Instance Method Details

#handle(options) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/props_template/extensions/fragment.rb', line 10

def handle(options)
  return if !options[:partial]
  partial_name, partial_opts = options[:partial]
  fragment = partial_opts[:fragment]

  if String === fragment || Symbol === fragment
    fragment_name = fragment.to_s
    path = @base.traveled_path.join(".")
    @name = fragment_name

    @fragments.push(
      {type: fragment_name, partial: partial_name, path: path}
    )
  end
end