fracassandra 0.3.3 → 0.3.4

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.3
1
+ 0.3.4
data/fracassandra.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{fracassandra}
8
- s.version = "0.3.3"
8
+ s.version = "0.3.4"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Jeremy Tregunna"]
12
- s.date = %q{2011-03-23}
12
+ s.date = %q{2011-03-24}
13
13
  s.description = %q{Hook your cassandra column families into ruby classes, mapping your rows to objects.}
14
14
  s.email = %q{jeremy.tregunna@me.com}
15
15
  s.extra_rdoc_files = [
data/lib/fracassandra.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # Frac.as Cassandra Library
2
2
  # Copyright © 2011, Jeremy Tregunna, All Rights Reserved.
3
3
 
4
- FRACASSANDRA_VERSION = "0.3.3"
4
+ FRACASSANDRA_VERSION = "0.3.4"
5
5
 
6
6
  require 'fracassandra/model'
7
7
 
@@ -52,10 +52,40 @@ module Fracassandra
52
52
  self.new(defaults)
53
53
  end
54
54
 
55
+ def self.from_hash(hash)
56
+ r = self.new
57
+ hash.each_pair do |k, v|
58
+ unless k.is_a? Cassandra::Long
59
+ r.send(:"#{k}=", v)
60
+ end
61
+ end
62
+ r
63
+ end
64
+
65
+ def self.all_keys
66
+ raise DatabaseError, "No database defined. Please set Frassandra.database= to a Cassandra connection." unless Fracassandra.database
67
+ raise DatabaseError, "No column family defined. Please edit your model." unless column_family
68
+
69
+ Fracassandra::database.get_range(column_family).map { |h| h.key }
70
+ end
71
+
72
+ def self.multi_get(*keys)
73
+ h = Fracassandra.database.get_range(column_family)
74
+ r = self.new
75
+ h.each_pair do |k, v|
76
+ unless k.is_a? Cassandra::Long
77
+ r.send(:"#{k}=", v)
78
+ end
79
+ end
80
+ r
81
+ end
82
+
55
83
  def self.[](key, sub_key=nil)
56
84
  raise DatabaseError, "No database defined. Please set Frassandra.database= to a Cassandra connection." unless Fracassandra.database
57
85
  raise DatabaseError, "No column family defined. Please edit your model." unless column_family
58
86
 
87
+ return self.multi_get(*key) if key.is_a? Array
88
+
59
89
  t = Fracassandra::database.get(column_family, key)
60
90
  return nil if t.nil?
61
91
  r = self.new
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fracassandra
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
4
+ hash: 27
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - 3
10
- version: 0.3.3
9
+ - 4
10
+ version: 0.3.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jeremy Tregunna
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-03-23 00:00:00 -04:00
18
+ date: 2011-03-24 00:00:00 -04:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency