datastax_rails 1.0.13.1 → 1.0.13.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -86,14 +86,21 @@ module DatastaxRails
86
86
  self.connection = CassandraCQL::Database.new(spec[:servers], {:keyspace => spec[:keyspace]}, connection_options.symbolize_keys)
87
87
  end
88
88
 
89
+ # Returns the base portion of the URL for connecting to SOLR based on the current Cassandra server.
90
+ #
91
+ # @return [String] in the form of 'http://localhost:8983/solr'
92
+ def solr_base_url
93
+ DatastaxRails::Base.establish_connection unless self.connection
94
+ port = DatastaxRails::Base.config[:solr][:port]
95
+ path = DatastaxRails::Base.config[:solr][:path]
96
+ "http://#{self.current_server}:#{port}#{path}"
97
+ end
98
+
89
99
  # Similar to +establish_connection+, this method creates a connection object for Solr. Since HTTP is stateless, this doesn't
90
100
  # actually launch the connection, but it gets everything set up so that RSolr can do its work. It's important to note that
91
101
  # unlike the cassandra connection which is global to all of DSR, each model will have its own solr_connection.
92
102
  def solr_connection
93
- DatastaxRails::Base.establish_connection unless self.connection
94
- port = DatastaxRails::Base.config[:solr][:port]
95
- path = DatastaxRails::Base.config[:solr][:path]
96
- @rsolr ||= DatastaxRails::RSolrClientWrapper.new(RSolr.connect :url => "http://#{self.current_server}:#{port}#{path}/#{DatastaxRails::Base.connection.keyspace}.#{self.column_family}")
103
+ @rsolr ||= DatastaxRails::RSolrClientWrapper.new(RSolr.connect :url => "#{solr_base_url}/#{DatastaxRails::Base.connection.keyspace}.#{self.column_family}")
97
104
  end
98
105
  end
99
106
  end
@@ -106,7 +106,7 @@ module DatastaxRails
106
106
  results = DatastaxRails::Cql::Select.new(SchemaMigration, ['*']).conditions(:key => model.column_family).execute
107
107
  sm_digests = CassandraCQL::Result.new(results).fetch.to_hash
108
108
 
109
- solr_url = "#{DatastaxRails::Base.config[:solr][:url]}/resource/#{DatastaxRails::Base.config[:keyspace]}.#{model.column_family}"
109
+ solr_url = "#{DatastaxRails::Base.solr_base_url}/resource/#{DatastaxRails::Base.config[:keyspace]}.#{model.column_family}"
110
110
  uri = URI.parse(solr_url)
111
111
  Net::HTTP.start(uri.host, uri.port) do |http|
112
112
  if force || solrconfig_digest != sm_digests['solrconfig']
@@ -1,7 +1,16 @@
1
1
  module DatastaxRails
2
2
  module Types
3
+ # ArrayType is used for storing arrays in Datastax Enterprise.
4
+ # They are indexed into SOLR as discrete values so that you can do something like this:
5
+ #
6
+ # Post.where(:tags => 'Technology')
7
+ #
8
+ # That would give you all the posts that have Technology somewhere in the tags array.
3
9
  class ArrayType < BaseType
4
10
  DEFAULTS = {:solr_type => 'array', :indexed => true, :stored => true, :multi_valued => false, :sortable => false, :tokenized => true, :fulltext => false}
11
+
12
+ # An extension to normal arrays that allow for tracking of dirty values. This is
13
+ # used by ActiveModel's change tracking framework.
5
14
  class DirtyArray < Array
6
15
  attr_accessor :record, :name, :options
7
16
  def initialize(record, name, array, options)
@@ -1,7 +1,13 @@
1
1
  module DatastaxRails
2
2
  module Types
3
+ # All of the DSR type classes inherit from here. It sets up some default options and doesn basic conversion
4
+ # to strings. Subclasses can override these methods as needed.
5
+ #
6
+ # NOTE: All subclasses MUST declare a +DEFAULTS+ constant that specifies the indexing defaults. Defaults may of
7
+ # course be overridden when the attribute is declared.
3
8
  class BaseType
4
9
  attr_accessor :options
10
+ # Default initializer. Sets the indexing options based on the DEFAULTS
5
11
  def initialize(options = {})
6
12
  @options = self.class::DEFAULTS.merge(options)
7
13
  end
@@ -1,4 +1,4 @@
1
1
  module DatastaxRails
2
2
  # The current version of the gem
3
- VERSION = "1.0.13.1"
3
+ VERSION = "1.0.13.2"
4
4
  end
@@ -1,6 +1,8 @@
1
1
  # Placeholder class to imitate a model for the schema migrations column family.
2
2
  # Used as part of the CQL generation.
3
3
  class SchemaMigration
4
+ class_attribute :default_consistency
5
+ self.default_consistency = :quorum
4
6
  # Returns the name of the column family
5
7
  def self.column_family
6
8
  'schema_migrations'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: datastax_rails
3
3
  version: !ruby/object:Gem::Version
4
- hash: 105
4
+ hash: 111
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
9
  - 13
10
- - 1
11
- version: 1.0.13.1
10
+ - 2
11
+ version: 1.0.13.2
12
12
  platform: ruby
13
13
  authors:
14
14
  - Jason M. Kusar
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2012-08-15 00:00:00 Z
19
+ date: 2012-08-17 00:00:00 Z
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
22
  name: rails