active_repository 0.2.1 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ODc4ODk0M2JiZTk5ZGE4ODZiYzM4OGRmNzNiZmYxODVlZjk1Yzg2Yg==
4
+ MjliYTU5ODNhMzMyZThjNWI4MGRjYmJkMTI2ZmRmYzgyOTFkZGQ4OA==
5
5
  data.tar.gz: !binary |-
6
- NDM4YjY5YjIyY2JhZTUxOWVjNzdkY2ZkYWFkMWYzZmI3YjQ2NzNkMQ==
6
+ NWJjYzEwNmVjN2NlYjVkNTM0ZTI1NjczYTZhOTA2MGU2Y2JhMjc1YQ==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- YWRmMTRiYzEwMjMwMjE2ZDg0YzJiZWE1MzEzZWI5MDViY2Q2ZDdjMDEyY2Rj
10
- MjVmNTI0MWYwODNhNzM2NzkzMzIzZTZiYzllYjg2ODA5NDgyMjM0OTgxNTQx
11
- N2U0NDI0MGRkZTk5OTNiOGZmYzYwNjY2MGNmMDhmZmY2MWI2YjQ=
9
+ NWFlMDExYTJmOGFmYzY1NzAxZmFjMDJiZDIwYmI5ZWNhMzhjMjI2NzkwM2Ey
10
+ NmVmODhlMzljMzAzYmU4YmJjNzZhNzAzYmVjOWZlMzhmYmIyNmZmOTk0NGNl
11
+ OTE2NDQxOGUzMzY4ZjM5MjZiYWM0MDEyMjk3ZmIwYTg5MmJjNDQ=
12
12
  data.tar.gz: !binary |-
13
- YjYzN2E1ZTdlOTI2ODMxYWVlZjlkYmM3NzgwNGRmZWQ0ODJlNDA0NjgyNmFj
14
- ZTM5MjRiODkzZTJmMWNhMmMzNjRiZjFkNjhjMmJkZDZlMDMxNDJhODQ5NThk
15
- OWI1N2RhNWM5ODA1NzU2ODhlMGQ2YzdmMWM5MTM5YjJlMmJlYmI=
13
+ YWZkYTZjMGU2ODQ4OGNhNWJjMGZlMTY0ZWJkYTY0YTk0Y2EwNjFjN2JhOTFm
14
+ ODI3NzdjNDliMmQ4N2NkZjVhZmExNzU4ODdlNTEwZTNmYTdmZmVlZDk2MTY2
15
+ ZTIyNDNmNjVlMjQzMjliNjE4NzJlZWIyOTYwZmJkODRjOGUxNWQ=
@@ -45,6 +45,7 @@ class DefaultAdapter
45
45
  end
46
46
 
47
47
  def where(klass, args)
48
+ # raise args.inspect
48
49
  klass.get_model_class.where(args)
49
50
  end
50
51
  end
@@ -150,7 +150,7 @@ module ActiveRepository
150
150
  super(query)
151
151
  else
152
152
  objects = []
153
- args = args.first.is_a?(Hash) ? args.first : args
153
+ args = args.first.is_a?(Hash) ? args.first : (args.first.is_a?(Array) ? args.first : args)
154
154
 
155
155
  PersistenceAdapter.where(self, args).each do |object|
156
156
  objects << self.serialize!(object.attributes)
@@ -7,7 +7,7 @@ module ActiveHash #:nodoc:
7
7
  return args.first if args.size == 1
8
8
 
9
9
  query = args.first
10
- param = args.delete(args[1])
10
+ param = args.delete_at(1)
11
11
 
12
12
  param = convert_param(param)
13
13
 
@@ -24,7 +24,7 @@ module ActiveHash #:nodoc:
24
24
  @operator.nil? ? @objects : @objects.send(@operator, execute(klass, @sub_query)).sort_by{ |o| o.id }
25
25
  end
26
26
 
27
- private
27
+ private
28
28
  # Splits the first sub query from the rest of the query and returns it.
29
29
  def divide_query
30
30
  array = @query.split(" ")
@@ -87,7 +87,7 @@ module ActiveHash #:nodoc:
87
87
  # Executes the #sub_quey defined operator filter
88
88
  def execute_operator(klass, sub_query)
89
89
  klass.all.select do |o|
90
- field, attribute = convert_attrs(o.send(sub_query.first), sub_query[2])
90
+ field, attribute = convert_attrs(o.send(sub_query.first.gsub(/[\(\)]/, "")), sub_query[2])
91
91
 
92
92
  field.blank? ? false : field.send(@operator, attribute)
93
93
  end
@@ -1,3 +1,3 @@
1
1
  module ActiveRepository
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.2"
3
3
  end
@@ -3,6 +3,7 @@ module ActiveRepository
3
3
  module Writers
4
4
  # Creates an object and persists it.
5
5
  def create(attributes={})
6
+ attributes = attributes.symbolize_keys if attributes.respond_to?(:symbolize_keys)
6
7
  object = self.new(attributes)
7
8
 
8
9
  if object.present? && object.valid?
@@ -306,6 +306,13 @@ shared_examples "and" do
306
306
  records.first.id.should == 2
307
307
  records.should == [Country.find(2), Country.find(4)]
308
308
  end
309
+
310
+ it "integer attribute and condition" do
311
+ records = Country.where("id = 2 and language = 'English'")
312
+ records.count.should == 2
313
+ records.first.id.should == 2
314
+ records.should == [Country.find(2), Country.find(4)]
315
+ end
309
316
  end
310
317
 
311
318
  shared_examples "or" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_repository
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Caio Torres
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-03-23 00:00:00.000000000 Z
11
+ date: 2013-05-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: active_hash