Class: Blocks::BlockDefinition

Inherits:
OptionsSet
  • Object
show all
Defined in:
lib/blocks/builders/block_definition.rb

Instance Attribute Summary

Attributes inherited from OptionsSet

#default_options, #name, #runtime_options, #standard_options

Instance Method Summary collapse

Methods inherited from OptionsSet

#add_options, #current_render_strategy_and_item, #initialize, #initialize_copy, #inspect, #nested_under_indifferent_access, #render_strategies_and_items, #reset

Constructor Details

This class inherits a constructor from Blocks::OptionsSet

Instance Method Details

#hooks_for(hook_name) ⇒ Object



23
24
25
# File 'lib/blocks/builders/block_definition.rb', line 23

def hooks_for(hook_name)
  self.send("#{hook_name}_hooks")
end

#skip(completely = false) ⇒ Object



10
11
12
13
# File 'lib/blocks/builders/block_definition.rb', line 10

def skip(completely=false)
  self.skip_content = true
  self.skip_completely = completely
end

#skip_completely?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/blocks/builders/block_definition.rb', line 19

def skip_completely?
  !!skip_completely
end

#skip_content?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/blocks/builders/block_definition.rb', line 15

def skip_content?
  !!skip_content
end

#to_sObject



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/blocks/builders/block_definition.rb', line 41

def to_s
  description = []
  description << super
  options = [
    runtime_options,
    standard_options,
    default_options
  ].detect(&:render_strategy)

  strategy = options.try(:render_strategy)
  render_strategy_name = if strategy == HashWithRenderStrategy::RENDER_WITH_PROXY
    caller_id = options.callers[HashWithRenderStrategy::RENDER_WITH_PROXY]
    "proxy block \"#{options[strategy]}\""
  elsif strategy == HashWithRenderStrategy::RENDER_WITH_BLOCK
    caller_id = options.callers[HashWithRenderStrategy::RENDER_WITH_BLOCK]
    "block defined at #{options[strategy].source_location}"
  elsif strategy == HashWithRenderStrategy::RENDER_WITH_PARTIAL
    caller_id = options.callers[HashWithRenderStrategy::RENDER_WITH_PARTIAL]
    "partial \"#{options[strategy]}\""
  end
  if render_strategy_name
    description << "Renders with #{render_strategy_name} [#{caller_id}]"
  end

  description.join("\n")
end