Class: Pigeon::Renderer::ChannelRenderer

Inherits:
Base
  • Object
show all
Includes:
ChannelHelper
Defined in:
app/helpers/pigeon/renderer/channel_renderer.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#delegate

Instance Method Summary collapse

Methods included from ChannelHelper

#pigeon_attribute, #pigeon_attribute_field, #pigeon_attribute_label, #pigeon_channel_attribute, #pigeon_channel_attribute_field, #pigeon_channel_attribute_label

Methods inherited from Base

#extract_options, find_handler, handle, #render, #render_at_command, #render_raw, #render_vector

Constructor Details

#initialize(channel = nil, scope = nil) ⇒ ChannelRenderer

Returns a new instance of ChannelRenderer.



14
15
16
17
# File 'app/helpers/pigeon/renderer/channel_renderer.rb', line 14

def initialize(channel = nil, scope = nil)
  self.channel = channel
  self.scope = scope
end

Instance Attribute Details

#channelObject

Returns the value of attribute channel.



7
8
9
# File 'app/helpers/pigeon/renderer/channel_renderer.rb', line 7

def channel
  @channel
end

#output_bufferObject

Returns the value of attribute output_buffer.



6
7
8
# File 'app/helpers/pigeon/renderer/channel_renderer.rb', line 6

def output_buffer
  @output_buffer
end

#scopeObject

Returns the value of attribute scope.



7
8
9
# File 'app/helpers/pigeon/renderer/channel_renderer.rb', line 7

def scope
  @scope
end

Instance Method Details

#render_attribute_command(v) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'app/helpers/pigeon/renderer/channel_renderer.rb', line 19

def render_attribute_command(v)
  command, options, content = extract_options(v)
  name = content.first
  options[:scope] = scope if scope.present?

  case command
  when '@field'
    pigeon_channel_attribute_field(channel, name, options)
  when '@label'
    pigeon_channel_attribute_label(channel, name, options)
  when '@attr'
    if options.include?(:class)
      options[:class] << ' pigeon_attribute'
    else
      options[:class] = 'pigeon_attribute'
    end
    pigeon_channel_attribute(channel, name, options)
  when '@hidden'
    options = options.update({ :type => :hidden })
    pigeon_channel_attribute_field(channel, name, options)
  else
    ''
  end
end

#render_template_command(v) ⇒ Object



44
45
46
47
48
49
50
51
52
53
# File 'app/helpers/pigeon/renderer/channel_renderer.rb', line 44

def render_template_command(v)
  command, options, content = extract_options(v)
  if %w(@wizard @template).include?(command)
    options["data-scope"] ||= scope if scope.present?
    options["data-persisted"] = channel.persisted?
    options["data-kind"] = channel.kind
    options["data-name"] = channel.name
  end
  super([command, options] + content)
end