Module: CassandraModel::Persistence::ClassMethods
- Defined in:
- lib/cassandra-model/persistence.rb
Instance Attribute Summary collapse
Instance Method Summary collapse
- #[](key) ⇒ Object
- #all(*args) ⇒ Object
- #create(attributes) ⇒ Object
- #exists?(key) ⇒ Boolean
- #find(*args) ⇒ Object
- #first(*args) ⇒ Object
- #get(key, options = {}) ⇒ Object
- #last(*args) ⇒ Object
-
#select(key, columns, options = {}) ⇒ Object
key column options.
- #where(search_clauses, select = [], options = {}) ⇒ Object
Instance Attribute Details
#read_consistency_level(level) ⇒ Object
67 68 69 |
# File 'lib/cassandra-model/persistence.rb', line 67 def read_consistency_level(level) @read_consistency_level = level end |
#write_consistency_level(level) ⇒ Object
63 64 65 |
# File 'lib/cassandra-model/persistence.rb', line 63 def write_consistency_level(level) @write_consistency_level = level end |
Instance Method Details
#[](key) ⇒ Object
75 76 77 78 79 |
# File 'lib/cassandra-model/persistence.rb', line 75 def [](key) record = get(key) raise RecordNotFound, "cannot find out key=`#{key}` in `#{column_family}`" unless record record end |
#all(*args) ⇒ Object
88 89 90 |
# File 'lib/cassandra-model/persistence.rb', line 88 def all(*args) find(:all, *args) end |
#create(attributes) ⇒ Object
57 58 59 60 61 |
# File 'lib/cassandra-model/persistence.rb', line 57 def create(attributes) new(attributes).tap do |object| object.save end end |
#exists?(key) ⇒ Boolean
81 82 83 84 85 86 |
# File 'lib/cassandra-model/persistence.rb', line 81 def exists?(key) return false if key.nil? || key == '' #connection.exists?(column_family, key) key = validate_key_type(key) !connection.get(column_family, key).empty? end |
#find(*args) ⇒ Object
100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/cassandra-model/persistence.rb', line 100 def find(*args) = args. () # set_readonly_option!(options) Not Implemented Yet case args.first when :first then find_initial() when :last then find_last() when :all then find_every() else find_from_ids(args, ) end end |
#first(*args) ⇒ Object
92 93 94 |
# File 'lib/cassandra-model/persistence.rb', line 92 def first(*args) find(:first, *args) end |
#get(key, options = {}) ⇒ Object
71 72 73 |
# File 'lib/cassandra-model/persistence.rb', line 71 def get(key, = {}) find_one(key, ) end |
#last(*args) ⇒ Object
96 97 98 |
# File 'lib/cassandra-model/persistence.rb', line 96 def last(*args) find(:last, *args) end |
#select(key, columns, options = {}) ⇒ Object
key column options
120 121 122 |
# File 'lib/cassandra-model/persistence.rb', line 120 def select(key, columns, = {}) find_select(key, columns, ) end |
#where(search_clauses, select = [], options = {}) ⇒ Object
113 114 115 |
# File 'lib/cassandra-model/persistence.rb', line 113 def where(search_clauses, select = [], = {}) find_where(search_clauses, select, ) end |