Class: Voom::Presenters::DSL::Components::Base

Inherits:
Object
  • Object
show all
Includes:
LoggerMethods, Mixins::YieldTo, Lockable, Serializer, Trace
Defined in:
lib/voom/presenters/dsl/components/base.rb

Overview

Every object in the POM is a node This class provides common base implementation

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Mixins::YieldTo

#yield_to

Methods included from Serializer

#to_hash

Methods included from Lockable

#lock!, #locked?

Constructor Details

#initialize(type:, parent:, id: nil, context: {}, **attributes, &block) ⇒ Base

Returns a new instance of Base.



26
27
28
29
30
31
32
33
# File 'lib/voom/presenters/dsl/components/base.rb', line 26

def initialize(type:, parent:, id: nil, context: {}, **attributes, &block)
  @id = h(id) || generate_id
  @type = h(type)
  @parent = parent
  @context = context
  @attributes = escape(attributes)
  @block = block
end

Instance Attribute Details

#attributesObject (readonly) Also known as: attribs

Returns the value of attribute attributes.



21
22
23
# File 'lib/voom/presenters/dsl/components/base.rb', line 21

def attributes
  @attributes
end

#contextObject (readonly) Also known as: params

Returns the value of attribute context.



21
22
23
# File 'lib/voom/presenters/dsl/components/base.rb', line 21

def context
  @context
end

#idObject (readonly)

Returns the value of attribute id.



21
22
23
# File 'lib/voom/presenters/dsl/components/base.rb', line 21

def id
  @id
end

#typeObject (readonly)

Returns the value of attribute type.



21
22
23
# File 'lib/voom/presenters/dsl/components/base.rb', line 21

def type
  @type
end

Instance Method Details

#expand!Object



35
36
37
38
# File 'lib/voom/presenters/dsl/components/base.rb', line 35

def expand!
  extend(_helpers_) if _helpers_
  instance_eval(&@block) if @block
end