de 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
data/lib/de/de.rb CHANGED
@@ -114,23 +114,30 @@ module De
114
114
  str
115
115
  end
116
116
 
117
- def to_hash
118
- {
119
- :name => @name,
120
- :content => @content,
121
- :class => self.class.name,
122
- :children => children.map { |child| child.to_hash }
123
- }
117
+ def copy
118
+ obj = self.clone
119
+ obj.parent = nil
120
+
121
+ obj
124
122
  end
125
123
 
126
- class << self
124
+ # def to_hash
125
+ # {
126
+ # :name => @name,
127
+ # :content => @content,
128
+ # :class => self.class.name,
129
+ # :children => children.map { |child| child.to_hash }
130
+ # }
131
+ # end
127
132
 
128
- def load(hash)
129
- raise Error::InvalidExpressionError if (hash.keys - [:name, :content, :class, :children]).length > 0
133
+ class << self
130
134
 
131
- obj = hash[:class].constantize.send(:new, hash[:name], hash[:content])
132
- hash[:children].each { |child| obj << load(child) }
133
- end
135
+ # def load(hash)
136
+ # raise Error::InvalidExpressionError if (hash.keys - [:name, :content, :class, :children]).length > 0
137
+ #
138
+ # obj = hash[:class].constantize.send(:new, hash[:name], hash[:content])
139
+ # hash[:children].each { |child| obj << load(child) }
140
+ # end
134
141
  end
135
142
 
136
143
  private
@@ -126,7 +126,8 @@ module De
126
126
  # Search object
127
127
  #
128
128
  def &(obj)
129
- Search.new("#{@name}+#{obj.name}", @klass, @options, [self.children, obj.children].flatten)
129
+ children = (self.children + obj.children).collect { |child| child.copy }
130
+ Search.new("#{@name}+#{obj.name}", @klass, @options, children)
130
131
  end
131
132
 
132
133
  #
@@ -146,12 +147,12 @@ module De
146
147
  [self, obj].select { |element| element.has_children? }.each do |element|
147
148
  if element.children.length == 1
148
149
  if element.first_child.is_a?(De::SunspotSolr::Or)
149
- element.first_child.children.each { |child| expression_content << child }
150
+ element.first_child.children.each { |child| expression_content << child.copy }
150
151
  else
151
- expression_content << element.first_child
152
+ expression_content << element.first_child.copy
152
153
  end
153
154
  else
154
- expression_content << SunspotSolr::And.new(element.children)
155
+ expression_content << SunspotSolr::And.new(element.children.collect { |child| child.copy })
155
156
  end
156
157
  end
157
158
 
data/lib/de/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module De
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: de
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
4
+ hash: 19
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 5
10
- version: 0.0.5
9
+ - 6
10
+ version: 0.0.6
11
11
  platform: ruby
12
12
  authors:
13
13
  - Olga Gorun
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-10-04 00:00:00 +02:00
18
+ date: 2011-10-23 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency