class XMLable::Handlers::Base
Base
contains base handlers logic
Attributes
block[R]
@return [#call] returns block with additional settings
type[R]
@return [Object]
Public Class Methods
build(*args, &block)
click to toggle source
Factory to build a handler
@return [XMLable::Handlers::Base]
# File lib/xmlable/handlers/base.rb, line 90 def self.build(*args, &block) name = args.shift.to_s opts = args.last.is_a?(Hash) ? args.pop : {} opts[:type] = args.shift if args.size > 0 opts[:container] = args.shift if args.size > 0 # standalone opts[:tag] = opts[:type].__tag if opts[:type].respond_to?(:__tag) new(name, opts, &block) end
new(name, opts = {}, &block)
click to toggle source
@param [String, Symbol] name element/attribute name @param [Hash] opts adtional handler options @option opts [Object] :tag element/attribute tag name @option opts [Object] :type element/attribute class object @option opts [Object] :container elements container
# File lib/xmlable/handlers/base.rb, line 20 def initialize(name, opts = {}, &block) @name = name.to_s @type = opts.delete(:type) || String @block = block end
Public Instance Methods
block_settings?()
click to toggle source
Does the handler have additional settings?
@return [Boolean]
# File lib/xmlable/handlers/base.rb, line 81 def block_settings? @block != nil end
inject_wraped(klass)
click to toggle source
Inject type class with addtional logic
@param [Class] klass
@return [Class]
# File lib/xmlable/handlers/base.rb, line 52 def inject_wraped(klass) end
method_name()
click to toggle source
Handler's element method name
@return [String]
# File lib/xmlable/handlers/base.rb, line 72 def method_name @name end
options()
click to toggle source
# File lib/xmlable/handlers/base.rb, line 63 def options proxy.__options end
options?()
click to toggle source
# File lib/xmlable/handlers/base.rb, line 59 def options? !options.nil? end
proxy()
click to toggle source
Proxy object which holds element data
@return [#new]
# File lib/xmlable/handlers/base.rb, line 41 def proxy raise NotImplementedError end
type_class()
click to toggle source
Type class for the handler element
@return [#new] returns class to store elements and attributes
# File lib/xmlable/handlers/base.rb, line 31 def type_class klass = Builder.proxy_for(@type) wrapped_type? ? inject_wraped(klass) : klass end
wrapped_type?()
click to toggle source
# File lib/xmlable/handlers/base.rb, line 55 def wrapped_type? Builder.wrapped_type?(type) end