Class: Deklarativna::Renderable

Inherits:
Object
  • Object
show all
Defined in:
lib/deklarativna_core.rb

Overview

Abstract Class Base Class for all renderables

Direct Known Subclasses

NestingRenderable, SingleTagRenderable

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(&initialization_block) ⇒ Renderable

Returns a new instance of Renderable.



8
9
10
# File 'lib/deklarativna_core.rb', line 8

def initialize &initialization_block
  initialization_block.call self
end

Instance Attribute Details

#attributesObject

Returns the value of attribute attributes.



6
7
8
# File 'lib/deklarativna_core.rb', line 6

def attributes
  @attributes
end

#tag_nameObject

Returns the value of attribute tag_name.



6
7
8
# File 'lib/deklarativna_core.rb', line 6

def tag_name
  @tag_name
end

Instance Method Details

#render_attributesObject

Private Method This method renders the attributes for any Renderable class



14
15
16
17
18
19
20
21
22
23
# File 'lib/deklarativna_core.rb', line 14

def render_attributes
  rendering_tags = []
  attribute_list = @attributes.sort if @attributes.respond_to? :sort
  if attribute_list.respond_to? :each
    attribute_list.each do |e|
      rendering_tags.push "#{e[0]}=\"#{e[1]}\""
    end
  end
  return " " + (rendering_tags.join " ") if !rendering_tags.empty?
end