Module: Halogen::InstanceMethods

Defined in:
lib/halogen.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#depthInteger

Returns the depth at which this representer is embedded.

Returns:

  • (Integer)

    the depth at which this representer is embedded


89
90
91
# File 'lib/halogen.rb', line 89

def depth
  @depth ||= parent ? parent.depth + 1 : 0
end

#initialize(options = {}) ⇒ Object

Returns the representer instance.

Parameters:

  • options (nil, Hash) (defaults to: {})

    hash of options

Returns:

  • (Object)

    the representer instance


64
65
66
# File 'lib/halogen.rb', line 64

def initialize(options = {})
  @options = Halogen::HashUtil.symbolize_keys!(options)
end

#parentnil, Object

Returns the parent representer, if this instance is an embedded child.

Returns:

  • (nil, Object)

    the parent representer, if this instance is an embedded child


83
84
85
# File 'lib/halogen.rb', line 83

def parent
  @parent ||= options.fetch(:parent, nil)
end

#renderHash

Returns rendered representation.

Returns:

  • (Hash)

    rendered representation


76
77
78
# File 'lib/halogen.rb', line 76

def render
  {}
end

#to_jsonString

Returns rendered JSON.

Returns:

  • (String)

    rendered JSON


70
71
72
# File 'lib/halogen.rb', line 70

def to_json
  render.to_json
end