Class: Halogen::Embeds::Definition

Inherits:
Definition show all
Defined in:
lib/halogen/embeds/definition.rb

Overview

:nodoc:

Instance Attribute Summary

Attributes inherited from Definition

#name, #options, #procedure

Instance Method Summary collapse

Methods inherited from Definition

#initialize, #value

Constructor Details

This class inherits a constructor from Halogen::Definition

Instance Method Details

#enabled?(instance) ⇒ true, false

Check whether this definition should be embedded for the given instance

Parameters:

  • instance (Object)

Returns:

  • (true, false)

24
25
26
27
28
29
30
31
32
# File 'lib/halogen/embeds/definition.rb', line 24

def enabled?(instance)
  return false unless super

  if instance.respond_to?(:embed?)
    instance.embed?(name.to_s)
  else
    embed_via_options?(instance)
  end
end

#validatetrue

Returns if nothing is raised.

Returns:

  • (true)

    if nothing is raised

Raises:


10
11
12
13
14
15
16
# File 'lib/halogen/embeds/definition.rb', line 10

def validate
  super

  return true if procedure

  fail InvalidDefinition, "Embed #{name} must be defined with a proc"
end