lib/voom/presenters/dsl/components/base.rb in voom-presenters-0.1.13 vs lib/voom/presenters/dsl/components/base.rb in voom-presenters-0.2.0
- old
+ new
@@ -1,11 +1,12 @@
-require_relative '../lockable'
-require_relative '../../../serializer'
-require_relative '../../../trace'
-require_relative 'mixins/yield_to'
require 'securerandom'
+require 'voom/serializer'
+require 'voom/trace'
+require 'voom/presenters/dsl/lockable'
+require 'voom/presenters/dsl/components/mixins/yield_to'
+
module Voom
module Presenters
module DSL
module Components
# Every object in the POM is a node
@@ -16,20 +17,19 @@
include Voom::Serializer
include LoggerMethods
include Trace
include Mixins::YieldTo
- attr_reader :type, :id, :attributes, :context
-
- alias params context
+ attr_reader :type, :id, :tag, :attributes
+
alias attribs attributes
- def initialize(type:, parent:, id: nil, context: {}, **attributes, &block)
+ def initialize(type:, parent:, id: nil, tag: nil, **attributes, &block)
@id = h(id) || generate_id
+ @tag = tag
@type = h(type)
@parent = parent
- @context = context
@attributes = escape(attributes)
@block = block
end
def expand!
@@ -61,10 +61,20 @@
def router
@parent.send(:router)
end
+ def namespace
+ @parent.send(:namespace)
+ end
+
+ def context
+ @parent.send(:context)
+ end
+ alias params context
+
+
def yield_block
return @_yield_block_ if @_yield_block_
@parent.send(:yield_block)
end
@@ -72,12 +82,11 @@
@parent.send(:_helpers_) if @parent
end
def default(key)
- Settings.config.presenters.components.defaults&.public_send(type)&.public_send(key)
+ Settings.default(type, key)
end
-
end
end
end
end
end