Module: Peanuts::MappableType

Includes:
Mappings
Defined in:
lib/peanuts/mappable.rb

Overview

See also MappableObject.

Constant Summary

Constants included from Mappings

Peanuts::Mappings::ShallowElement

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.init(cls, ns_context = nil, default_ns = nil, &block) ⇒ Object

:nodoc:



46
47
48
49
50
51
52
53
# File 'lib/peanuts/mappable.rb', line 46

def self.init(cls, ns_context = nil, default_ns = nil, &block) #:nodoc:
  cls.instance_eval do
    extend MappableType
    @mapper = Mapper.new(ns_context, default_ns)
    instance_eval(&block) if block_given?
  end
  cls
end

.macro(&block) ⇒ Object



59
60
61
62
63
64
65
66
67
# File 'lib/peanuts/mappable.rb', line 59

def self.macro(&block)
  Module.new do |mod|
    @@macro_proc = block
    def self.included(other)
      other.send(:include, MappableObject)
      other.instance_eval(&@@macro_proc)
    end
  end
end

.object_type?(type) ⇒ Boolean

Returns:

  • (Boolean)


55
56
57
# File 'lib/peanuts/mappable.rb', line 55

def self.object_type?(type)
  type.is_a?(Class) && !(type < Converter)
end

Instance Method Details

#from_xml(source, options = {}) ⇒ Object



69
70
71
# File 'lib/peanuts/mappable.rb', line 69

def from_xml(source, options = {})
  new.from_xml(source, options)
end