rdy 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/README.md +6 -0
  2. data/VERSION +1 -1
  3. data/lib/rdy.rb +9 -9
  4. metadata +3 -3
data/README.md CHANGED
@@ -25,6 +25,12 @@ Fun little ruby client for Amazon DynamoDB.
25
25
 
26
26
  Advanced features like queries, scans etc. are not supported yet.
27
27
 
28
+ ## Installation
29
+
30
+ gem install rdy
31
+
32
+ Then create a .rdy.yml file with your AWS credentials in your home directory. Checkout the sample file for help. Also make sure you activate DynamoDB in your AWS account.
33
+
28
34
  ## Contributing to rdy
29
35
 
30
36
  * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.1
1
+ 0.1.2
data/lib/rdy.rb CHANGED
@@ -11,7 +11,6 @@ class Rdy
11
11
  @_table = Rdy.dynamo_db.tables[@table]
12
12
  @_table.status
13
13
  end
14
-
15
14
  def table=(value); @table = value; end
16
15
  def table; @table; end
17
16
  def attributes; @attributes; end
@@ -24,7 +23,6 @@ class Rdy
24
23
  @@dynamo_db = AWS::DynamoDB.new(:access_key_id => config['access_key_id'],
25
24
  :secret_access_key => config['secret_access_key'])
26
25
  end
27
-
28
26
  def self.create_table(table, read_capacity_units, write_capacity_units, hash_key, range_key = nil)
29
27
  dynamo_db.tables.create(table, read_capacity_units, write_capacity_units,
30
28
  :hash_key => hash_key, :range_key => range_key)
@@ -32,9 +30,10 @@ class Rdy
32
30
 
33
31
  def all; @_table.items.collect {|i| i.attributes.to_h }; end
34
32
  def find(hash_value)
35
- it = @_table.items[hash_value]
33
+ raise "missing hash value" if hash_value.nil?
34
+ @_item = @_table.items[hash_value]
36
35
  @attributes.clear
37
- it.attributes.to_h.each {|k, v| self.send("#{k}=".to_sym, v) unless k == @hash_key }
36
+ @_item.attributes.to_h.each {|k, v| self.send("#{k}=".to_sym, v) unless k == @hash_key }
38
37
  @hash_value = hash_value; @is_new = false
39
38
  @attributes
40
39
  end
@@ -42,7 +41,7 @@ class Rdy
42
41
  def is_new?; @is_new; end
43
42
  def save(hash_value = nil)
44
43
  raise "missing hash value" if hash_value.nil? and is_new?
45
- @_item = item = @_table.items.create(@hash_key.to_sym => hash_value) if is_new?
44
+ @_item = @_table.items.create(@hash_key.to_sym => hash_value) if is_new?
46
45
  if @_item
47
46
  @_item.attributes.set(@attributes)
48
47
  @is_new = false; @hash_value = hash_value
@@ -53,19 +52,20 @@ class Rdy
53
52
  def destroy
54
53
  unless is_new?
55
54
  @_item.delete
56
- @hash_value = nil; @is_new = true
55
+ @hash_value = nil; @_item = nil; @is_new = true
57
56
  end
58
57
  end
59
58
 
59
+ private
60
60
  def method_missing(method, *args, &block)
61
61
  if RESERVED.include?(method.to_s)
62
62
  self.send(method.to_sym, *args, &block)
63
63
  else
64
- if method.to_s.include?("=")
65
- @attributes[method.to_s.gsub("=","")] = args.first
64
+ if method.to_s[-1, 1] == '='
65
+ @attributes[method.to_s.gsub('=', '')] = args.first
66
66
  else
67
67
  @attributes[method.to_s]
68
68
  end
69
69
  end
70
70
  end
71
- end
71
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rdy
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 31
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 1
10
- version: 0.1.1
9
+ - 2
10
+ version: 0.1.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Oliver Kiessler