peanuts 2.1 → 2.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -54,6 +54,16 @@ module Peanuts #:nodoc:
54
54
  type.is_a?(Class) && !(type < Converter)
55
55
  end
56
56
 
57
+ def self.macro(&block)
58
+ Module.new do |mod|
59
+ @@macro_proc = block
60
+ def self.included(other)
61
+ other.send(:include, MappableObject)
62
+ other.instance_eval(&@@macro_proc)
63
+ end
64
+ end
65
+ end
66
+
57
67
  def from_xml(source, options = {})
58
68
  new.from_xml(source, options)
59
69
  end
data/lib/peanuts.rb CHANGED
@@ -1,7 +1,12 @@
1
1
  require 'peanuts/mappable'
2
2
 
3
3
  module Peanuts #:nodoc:
4
+ # Deprecated. Include Peanuts::MappableObject instead.
4
5
  def self.included(other)
5
- other.send(:include, MappableObject)
6
+ other.send(:include, MappableObject) if ![Object, Kernel].include?(other)
7
+ end
8
+
9
+ def self.macro(&block)
10
+ MappableType.macro(&block)
6
11
  end
7
12
  end
data/spec/cat_spec.rb CHANGED
@@ -7,7 +7,7 @@ require 'peanuts'
7
7
 
8
8
 
9
9
  class Cheezburger
10
- include Peanuts
10
+ include Peanuts::MappableObject
11
11
 
12
12
  attribute :weight, :float
13
13
  attribute :price, :decimal
@@ -24,13 +24,13 @@ class Cheezburger
24
24
  end
25
25
 
26
26
  class Paws
27
- include Peanuts
27
+ include Peanuts::MappableObject
28
28
 
29
29
  elements :paws, :name => :paw, :ns => 'urn:x-lol'
30
30
  end
31
31
 
32
32
  class Cat
33
- include Peanuts
33
+ include Peanuts::MappableObject
34
34
 
35
35
  namespaces :lol => 'urn:x-lol', :kthnx => 'urn:x-lol:kthnx'
36
36
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: peanuts
3
3
  version: !ruby/object:Gem::Version
4
- version: "2.1"
4
+ version: 2.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Igor Gunko
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-01-30 00:00:00 +02:00
12
+ date: 2010-01-31 00:00:00 +02:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency