Class: Dock::ActiveRecord

Inherits:
Base
  • Object
show all
Defined in:
lib/dock/adapters/active_record.rb

Instance Attribute Summary

Attributes inherited from Base

#model

Instance Method Summary collapse

Methods inherited from Base

#embedded, inherited, #initialize, #scoped

Constructor Details

This class inherits a constructor from Dock::Base

Instance Method Details

#all(options = {}) ⇒ Object

Checked



18
19
20
# File 'lib/dock/adapters/active_record.rb', line 18

def all(options = {})
  construct_relation(model, options)
end

#associationsObject



38
39
40
# File 'lib/dock/adapters/active_record.rb', line 38

def associations()

end

#belongs_toObject



57
58
59
# File 'lib/dock/adapters/active_record.rb', line 57

def belongs_to()

end

#column_namesObject

Checked



46
47
48
# File 'lib/dock/adapters/active_record.rb', line 46

def column_names
  model.column_names
end

#count(options = {}) ⇒ Object

Checked



50
51
52
# File 'lib/dock/adapters/active_record.rb', line 50

def count(options = {})
  all(options).count
end

#create(attributes = {}) ⇒ Object

Checked



6
7
8
# File 'lib/dock/adapters/active_record.rb', line 6

def create(attributes = {})
  model.create!(attributes)
end

#cyclic?Boolean

Checked

Returns:

  • (Boolean)


72
73
74
# File 'lib/dock/adapters/active_record.rb', line 72

def cyclic?
  false
end

#destroy(object) ⇒ Object

Checked



35
36
37
# File 'lib/dock/adapters/active_record.rb', line 35

def destroy(object)
  object.destroy && true if valid_object?(object)
end

#embedded?Boolean

Checked

Returns:

  • (Boolean)


68
69
70
# File 'lib/dock/adapters/active_record.rb', line 68

def embedded?
  false
end

#encodingObject

Checked



54
55
56
# File 'lib/dock/adapters/active_record.rb', line 54

def encoding
  model.client_encoding()
end

#find(id) ⇒ Object

Checked



10
11
12
# File 'lib/dock/adapters/active_record.rb', line 10

def find(id)
  model.find(wrap_key(id))
end

#find!(id) ⇒ Object

Checked



14
15
16
# File 'lib/dock/adapters/active_record.rb', line 14

def find!(id)
  model.where(model.primary_key => wrap_key(id)).first
end

#first(options = {}) ⇒ Object

Checked



22
23
24
# File 'lib/dock/adapters/active_record.rb', line 22

def first(options = {})
  construct_relation(model, options).first
end

#has_manyObject



60
61
62
# File 'lib/dock/adapters/active_record.rb', line 60

def has_many()

end

#idObject

Checked



26
27
28
# File 'lib/dock/adapters/active_record.rb', line 26

def id
  model.id
end

#model_nameObject

Checked



42
43
44
# File 'lib/dock/adapters/active_record.rb', line 42

def model_name
  model.model_name
end

#order_clause(order) ⇒ Object



112
113
114
# File 'lib/dock/adapters/active_record.rb', line 112

def order_clause(order)
  order.map {|pair| "#{pair[0]} #{pair[1]}"}.join(",")
end

#propertiesObject



79
80
81
# File 'lib/dock/adapters/active_record.rb', line 79

def properties()

end

#scoped?Boolean

Checked

Returns:

  • (Boolean)


64
65
66
# File 'lib/dock/adapters/active_record.rb', line 64

def scoped?
  model.all
end

#supports_joins?Boolean

Checked

Returns:

  • (Boolean)


76
77
78
# File 'lib/dock/adapters/active_record.rb', line 76

def supports_joins?
  true
end

#update(search_key, find_by, update_key, by_value) ⇒ Object

Checked



30
31
32
33
# File 'lib/dock/adapters/active_record.rb', line 30

def update(search_key, find_by, update_key, by_value)
  entry = model.find_by(search_key find_by)
  entry.update(update_key by_value)
end