Class: XMLable::Handlers::Base
- Inherits:
-
Object
- Object
- XMLable::Handlers::Base
- Defined in:
- lib/xmlable/handlers/base.rb
Overview
Base contains base handlers logic
Instance Attribute Summary collapse
-
#block ⇒ #call
readonly
Returns block with additional settings.
- #type ⇒ Object readonly
Class Method Summary collapse
-
.build(*args, &block) ⇒ XMLable::Handlers::Base
Factory to build a handler.
Instance Method Summary collapse
-
#block_settings? ⇒ Boolean
Does the handler have additional settings?.
-
#initialize(name, opts = {}, &block) ⇒ Base
constructor
A new instance of Base.
-
#inject_wraped(klass) ⇒ Class
Inject type class with addtional logic.
-
#method_name ⇒ String
Handler’s element method name.
- #options ⇒ Object
- #options? ⇒ Boolean
-
#proxy ⇒ #new
Proxy object which holds element data.
-
#type_class ⇒ #new
Type class for the handler element.
- #wrapped_type? ⇒ Boolean
Constructor Details
#initialize(name, opts = {}, &block) ⇒ Base
Returns a new instance of Base.
20 21 22 23 24 |
# 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 |
Instance Attribute Details
#block ⇒ #call (readonly)
Returns block with additional settings
11 12 13 |
# File 'lib/xmlable/handlers/base.rb', line 11 def block @block end |
#type ⇒ Object (readonly)
8 9 10 |
# File 'lib/xmlable/handlers/base.rb', line 8 def type @type end |
Class Method Details
.build(*args, &block) ⇒ XMLable::Handlers::Base
Factory to build a handler
90 91 92 93 94 95 96 97 98 99 100 |
# 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 |
Instance Method Details
#block_settings? ⇒ Boolean
Does the handler have additional settings?
81 82 83 |
# File 'lib/xmlable/handlers/base.rb', line 81 def block_settings? @block != nil end |
#inject_wraped(klass) ⇒ Class
Inject type class with addtional logic
52 53 |
# File 'lib/xmlable/handlers/base.rb', line 52 def inject_wraped(klass) end |
#method_name ⇒ String
Handler’s element method name
72 73 74 |
# File 'lib/xmlable/handlers/base.rb', line 72 def method_name @name end |
#options ⇒ Object
63 64 65 |
# File 'lib/xmlable/handlers/base.rb', line 63 def proxy. end |
#options? ⇒ Boolean
59 60 61 |
# File 'lib/xmlable/handlers/base.rb', line 59 def !.nil? end |
#proxy ⇒ #new
Proxy object which holds element data
41 42 43 |
# File 'lib/xmlable/handlers/base.rb', line 41 def proxy raise NotImplementedError end |
#type_class ⇒ #new
Type class for the handler element
31 32 33 34 |
# 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? ⇒ Boolean
55 56 57 |
# File 'lib/xmlable/handlers/base.rb', line 55 def wrapped_type? Builder.wrapped_type?(type) end |