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

Inherits:
Object
  • Object
show all
Extended by:
Pluggable
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 Pluggable

include_plugins, plugin_module

Methods included from Mixins::YieldTo

#yield_to

Methods included from Serializer

#to_hash

Methods included from Lockable

#locked?

Constructor Details

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

Returns a new instance of Base.



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

def initialize(type:, parent:, id: nil, tag: nil, **attributes, &block)
  @draggable = attributes.delete(:draggable) {nil}
  @drop_zone = attributes.delete(:drop_zone) {nil}
  @css_class = Array(attributes.delete(:class) {nil})
  @id = id || generate_id
  @tag = tag
  @type = type
  @parent = parent
  @attributes = attributes
  @block = block
  initialize_plugins
end

Instance Attribute Details

#attributesObject (readonly) Also known as: attribs

Returns the value of attribute attributes.



18
19
20
# File 'lib/voom/presenters/dsl/components/base.rb', line 18

def attributes
  @attributes
end

#css_classObject (readonly)

Returns the value of attribute css_class.



18
19
20
# File 'lib/voom/presenters/dsl/components/base.rb', line 18

def css_class
  @css_class
end

#draggableObject (readonly)

Returns the value of attribute draggable.



18
19
20
# File 'lib/voom/presenters/dsl/components/base.rb', line 18

def draggable
  @draggable
end

#drop_zoneObject (readonly)

Returns the value of attribute drop_zone.



18
19
20
# File 'lib/voom/presenters/dsl/components/base.rb', line 18

def drop_zone
  @drop_zone
end

#idObject (readonly)

Returns the value of attribute id.



18
19
20
# File 'lib/voom/presenters/dsl/components/base.rb', line 18

def id
  @id
end

#tagObject (readonly)

Returns the value of attribute tag.



18
19
20
# File 'lib/voom/presenters/dsl/components/base.rb', line 18

def tag
  @tag
end

#typeObject (readonly)

Returns the value of attribute type.



18
19
20
# File 'lib/voom/presenters/dsl/components/base.rb', line 18

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