cql_model 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -27,9 +27,9 @@ Or install it yourself as:
27
27
  class Person < Cql::Model
28
28
  primary_key :id
29
29
 
30
- column :first_name, String
31
- column :last_name, String
32
- column :dob, Date
30
+ column :first_name
31
+ column :last_name
32
+ column :dob
33
33
  end
34
34
 
35
35
  ### Schema Definition
@@ -48,16 +48,26 @@ work with. The default primary key is `id`.
48
48
 
49
49
  #### Columns
50
50
 
51
- You define columns by supplying the attribute name, Ruby class for type
52
- conversion and an optional set of options.
51
+ You define columns by supplying the attribute name and an optional set of
52
+ options.
53
53
 
54
- column :first_name, String
55
- column :birth_date, Date
56
- column :birth_date, Date, column_name: :dob
54
+ column :first_name
55
+ column :birth_date
56
+ column :birth_date, column_name: :dob
57
57
 
58
58
  The supported options for columns are as follows:
59
59
 
60
60
  * `column_name`: actual column name for storing the attribute.
61
+ * `ready_only`: flags the attribute as read-only, blocking creation of a setter
62
+ method.
63
+
64
+ #### Consistency
65
+
66
+ You can set any consistency value for your models that is supported by cql-rb
67
+ and it will be passed whenever a query is executed. The default consistency
68
+ level is `quorum`.
69
+
70
+ consistency :three
61
71
 
62
72
  ## Contributing
63
73
 
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
10
10
  spec.email = %w{james@plainprograms.com'}
11
11
  spec.description = %q{An ActiveModel implementation on top of the cql-rb gem}
12
12
  spec.summary = %q{ActiveModel implementation on cql-rb}
13
- spec.homepage = 'https://github.com/plainprogrammer/cql_model'
13
+ spec.homepage = 'http://plainprogrammer.github.io/cql_model/'
14
14
  spec.license = 'MIT'
15
15
 
16
16
  spec.files = `git ls-files`.split($/)
@@ -5,6 +5,7 @@ require 'active_support/core_ext'
5
5
 
6
6
  require 'cql/base'
7
7
  require 'cql/model/version'
8
+
8
9
  require 'cql/model/schema_methods'
9
10
  require 'cql/model/finder_methods'
10
11
  require 'cql/model/persistence_methods'
@@ -59,7 +60,7 @@ module Cql
59
60
  end
60
61
 
61
62
  def self.execute(query)
62
- cql_results = Cql::Base.connection.execute(query)
63
+ cql_results = Cql::Base.connection.execute(query, consistency)
63
64
  Cql::Model::QueryResult.new(cql_results, self)
64
65
  end
65
66
  end
@@ -9,6 +9,10 @@ module Cql::Model::SchemaMethods
9
9
  self.class.primary_key
10
10
  end
11
11
 
12
+ def consistency
13
+ self.class.consistency
14
+ end
15
+
12
16
  module ClassMethods
13
17
  def table_name
14
18
  @table_name ||= self.model_name.plural
@@ -18,17 +22,20 @@ module Cql::Model::SchemaMethods
18
22
  @columns ||= {}
19
23
  end
20
24
 
25
+ def consistency(consistency_value = nil)
26
+ @consistency ||= consistency_value.nil? ? :quorum : consistency_value.to_sym
27
+ end
28
+
21
29
  def primary_key(key_name = nil)
22
30
  @primary_key ||= key_name.nil? ? 'id' : key_name.to_s
23
31
  end
24
32
 
25
- def column(attribute_name, ruby_class, options = {})
33
+ def column(attribute_name, options = {})
26
34
  column_name = options[:column_name] || attribute_name
27
35
 
28
36
  @columns ||= {}
29
37
  @columns[column_name.to_sym] = {
30
38
  attribute_name: attribute_name.to_sym,
31
- klass: ruby_class.to_s.constantize
32
39
  }.merge(options)
33
40
  end
34
41
  end
@@ -1,5 +1,5 @@
1
1
  module Cql
2
2
  class Model
3
- VERSION = '0.0.4'
3
+ VERSION = '0.0.5'
4
4
  end
5
5
  end
@@ -20,14 +20,14 @@ setup_cql_test
20
20
  class Event < Cql::Model
21
21
  primary_key :id
22
22
 
23
- column :location, String
24
- column :date, Date
23
+ column :location
24
+ column :date
25
25
  end
26
26
 
27
27
  class Person < Cql::Model
28
28
  primary_key :id
29
29
 
30
- column :first_name, String
31
- column :last_name, String
32
- column :birth_date, Date, column_name: :dob
30
+ column :first_name
31
+ column :last_name
32
+ column :birth_date, column_name: :dob
33
33
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cql_model
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-06-23 00:00:00.000000000 Z
12
+ date: 2013-06-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: cql-rb
@@ -151,7 +151,7 @@ files:
151
151
  - spec/cql/model/query_result_spec.rb
152
152
  - spec/spec_helper.rb
153
153
  - spec/support/setup_test_keyspace.rb
154
- homepage: https://github.com/plainprogrammer/cql_model
154
+ homepage: http://plainprogrammer.github.io/cql_model/
155
155
  licenses:
156
156
  - MIT
157
157
  post_install_message:
@@ -166,7 +166,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
166
166
  version: '0'
167
167
  segments:
168
168
  - 0
169
- hash: -2300288373958290693
169
+ hash: 2223011310756065091
170
170
  required_rubygems_version: !ruby/object:Gem::Requirement
171
171
  none: false
172
172
  requirements:
@@ -175,7 +175,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
175
175
  version: '0'
176
176
  segments:
177
177
  - 0
178
- hash: -2300288373958290693
178
+ hash: 2223011310756065091
179
179
  requirements: []
180
180
  rubyforge_project:
181
181
  rubygems_version: 1.8.23