Sha256: e113ce725b8c9489a01fdcb6e954671da34397f41c700c7b07fbf986be080a93

Contents?: true

Size: 1.03 KB

Versions: 4

Compression:

Stored size: 1.03 KB

Contents

# File: unary-element.rb
# Purpose: Implementation of the Section and ConditionalSection classes.


module Macros4Cuke # Module used as a namespace

  # Base class used internally by the template engine.
  # The generalization of any element from a template that has one variable
  # whose actual value influences the rendition.
  class UnaryElement
    # The name of the placeholder/variable.
    attr_reader(:name)

    # @param aVarName [String] The name of the placeholder from a template.
    def initialize(aVarName)
      @name = aVarName
    end

    protected

    # This method has the same signature as the {Engine#render} method.
    # @return [Object] The actual value from the locals or context
    # that is assigned to the variable.
    def retrieve_value_from(aContextObject, theLocals)
      actual_value = theLocals[name]
      if actual_value.nil? && aContextObject.respond_to?(name.to_sym)
        actual_value = aContextObject.send(name.to_sym)
      end

      return actual_value
    end

  end # class

end # module

# End of file

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
macros4cuke-0.5.07 lib/macros4cuke/templating/unary-element.rb
macros4cuke-0.5.06 lib/macros4cuke/templating/unary-element.rb
macros4cuke-0.5.03 lib/macros4cuke/templating/unary-element.rb
macros4cuke-0.4.09 lib/macros4cuke/templating/unary-element.rb