lib/pakyow/presenter/view.rb in pakyow-presenter-1.0.0.rc2 vs lib/pakyow/presenter/view.rb in pakyow-presenter-1.0.0.rc3
- old
+ new
@@ -41,10 +41,11 @@
end
instance
end
+ # @api private
def from_view_or_string(view_or_string)
case view_or_string
when View, VersionedView
view_or_string
else
@@ -60,22 +61,19 @@
extend Forwardable
def_delegators :@object, :type, :text, :html, :label, :labeled?
- # The object responsible for parsing, manipulating, and rendering
- # the underlying HTML document for the view.
+ # The object responsible for transforming and rendering the underlying document or node.
#
- attr_reader :object
+ # @api private
+ attr_accessor :object
# The logical path to the view template.
#
attr_reader :logical_path
- # @api private
- attr_writer :object
-
# Creates a view with +html+.
#
def initialize(html, info: {}, logical_path: nil)
@object = StringDoc.new(html)
@info, @logical_path = Support::IndifferentHash.deep(info), logical_path
@@ -98,10 +96,11 @@
else
@attributes = nil
end
end
+ # @api private
def soft_copy
instance = self.class.allocate
instance.instance_variable_set(:@info, @info.dup)
@@ -146,31 +145,33 @@
end
end
# Finds all view bindings by name, returning an array of {View} objects.
#
+ # @api private
def find_all(named)
each_binding(named).map { |node|
View.from_object(node)
}
end
# Finds a form with a binding matching +name+.
#
def form(name)
@object.each_significant_node(:form) do |form_node|
- return Form.from_object(form_node) if form_node.label(:binding) == name
+ return Views::Form.from_object(form_node) if form_node.label(:binding) == name
end
nil
end
# Returns all forms.
#
+ # @api private
def forms
@object.each_significant_node(:form, descend: true).map { |node|
- Form.from_object(node)
+ Views::Form.from_object(node)
}
end
# Finds a component matching +name+.
#
@@ -183,10 +184,11 @@
}
end
# Returns all components.
#
+ # @api private
def components(renderable: false)
@object.each_significant_node_without_descending_into_type(:component, descend: true).select { |node|
!renderable || node.label(:components).any? { |component| component[:renderable] }
}.map { |node|
View.from_object(node)
@@ -565,10 +567,10 @@
}.any? { |node|
node.label(:channel).any?
}
end
- protected
+ private
def bind_value_to_node(value, node)
tag = node.tagname
unless StringDoc::Node.without_value?(tag)
value = String(value)