Module: Halogen::InstanceMethods

Defined in:
lib/halogen.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#collection?Boolean

Returns:

  • (Boolean)


95
96
97
# File 'lib/halogen.rb', line 95

def collection?
  false
end

#depthInteger

Returns the depth at which this representer is embedded.

Returns:

  • (Integer)

    the depth at which this representer is embedded



91
92
93
# File 'lib/halogen.rb', line 91

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



66
67
68
# File 'lib/halogen.rb', line 66

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



85
86
87
# File 'lib/halogen.rb', line 85

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

#renderHash

Returns rendered representation.

Returns:

  • (Hash)

    rendered representation



78
79
80
# File 'lib/halogen.rb', line 78

def render
  {}
end

#to_jsonString

Returns rendered JSON.

Returns:

  • (String)

    rendered JSON



72
73
74
# File 'lib/halogen.rb', line 72

def to_json
  render.to_json
end