Class: Tailmix::Definition::Result::Element

Inherits:
Struct
  • Object
show all
Defined in:
lib/tailmix/definition/result.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#attribute_bindingsObject

Returns the value of attribute attribute_bindings

Returns:

  • (Object)

    the current value of attribute_bindings



19
20
21
# File 'lib/tailmix/definition/result.rb', line 19

def attribute_bindings
  @attribute_bindings
end

#attributesObject

Returns the value of attribute attributes

Returns:

  • (Object)

    the current value of attributes



19
20
21
# File 'lib/tailmix/definition/result.rb', line 19

def attributes
  @attributes
end

#compound_variantsObject

Returns the value of attribute compound_variants

Returns:

  • (Object)

    the current value of compound_variants



19
20
21
# File 'lib/tailmix/definition/result.rb', line 19

def compound_variants
  @compound_variants
end

#default_attributesObject

Returns the value of attribute default_attributes

Returns:

  • (Object)

    the current value of default_attributes



19
20
21
# File 'lib/tailmix/definition/result.rb', line 19

def default_attributes
  @default_attributes
end

#dimensionsObject

Returns the value of attribute dimensions

Returns:

  • (Object)

    the current value of dimensions



19
20
21
# File 'lib/tailmix/definition/result.rb', line 19

def dimensions
  @dimensions
end

#event_bindingsObject

Returns the value of attribute event_bindings

Returns:

  • (Object)

    the current value of event_bindings



19
20
21
# File 'lib/tailmix/definition/result.rb', line 19

def event_bindings
  @event_bindings
end

#model_bindingsObject

Returns the value of attribute model_bindings

Returns:

  • (Object)

    the current value of model_bindings



19
20
21
# File 'lib/tailmix/definition/result.rb', line 19

def model_bindings
  @model_bindings
end

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



19
20
21
# File 'lib/tailmix/definition/result.rb', line 19

def name
  @name
end

Instance Method Details

#to_hObject



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/tailmix/definition/result.rb', line 20

def to_h
  {
    name: name,
    attributes: attributes.to_h,
    default_attributes: default_attributes,
    dimensions: dimensions.transform_values do |dimension|
      dimension.transform_values do |value|
        case value
        when Variant
          value.to_h
        when Hash
          value.transform_values { |v| v.respond_to?(:to_h) ? v.to_h : v }
        else
          value
        end
      end
    end,
    compound_variants: compound_variants,
    attribute_bindings: attribute_bindings,
    model_bindings: model_bindings,
  }
end