Class: Horza::Adapters::AbstractAdapter

Inherits:
Object
  • Object
show all
Defined in:
lib/horza/adapters/abstract_adapter.rb

Direct Known Subclasses

ActiveRecord

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(context) ⇒ AbstractAdapter

Returns a new instance of AbstractAdapter.



24
25
26
# File 'lib/horza/adapters/abstract_adapter.rb', line 24

def initialize(context)
  @context = context
end

Instance Attribute Details

#contextObject (readonly)

Returns the value of attribute context.



4
5
6
# File 'lib/horza/adapters/abstract_adapter.rb', line 4

def context
  @context
end

Class Method Details

.context_for_entity(entity) ⇒ Object



11
12
13
# File 'lib/horza/adapters/abstract_adapter.rb', line 11

def context_for_entity(entity)
  not_implemented_error
end

.entity_context_mapObject



15
16
17
# File 'lib/horza/adapters/abstract_adapter.rb', line 15

def entity_context_map
  not_implemented_error
end

.expected_errorsObject



7
8
9
# File 'lib/horza/adapters/abstract_adapter.rb', line 7

def expected_errors
  not_implemented_error
end

.not_implemented_errorObject



19
20
21
# File 'lib/horza/adapters/abstract_adapter.rb', line 19

def not_implemented_error
  raise ::Horza::Errors::MethodNotImplemented, 'You must implement this method in your adapter.'
end

Instance Method Details

#ancestors(options = {}) ⇒ Object



50
51
52
# File 'lib/horza/adapters/abstract_adapter.rb', line 50

def ancestors(options = {})
  not_implemented_error
end

#eager_load(options = {}) ⇒ Object



54
55
56
# File 'lib/horza/adapters/abstract_adapter.rb', line 54

def eager_load(options = {})
  not_implemented_error
end

#entity_class(res = @context) ⇒ Object



62
63
64
# File 'lib/horza/adapters/abstract_adapter.rb', line 62

def entity_class(res = @context)
  collection?(res) ? ::Horza::Entities.collection_entity_for(entity_symbol).new(res) : ::Horza::Entities.single_entity_for(entity_symbol).new(res)
end

#find_all(options = {}) ⇒ Object



46
47
48
# File 'lib/horza/adapters/abstract_adapter.rb', line 46

def find_all(options = {})
  not_implemented_error
end

#find_first(options = {}) ⇒ Object



37
38
39
40
# File 'lib/horza/adapters/abstract_adapter.rb', line 37

def find_first(options = {})
  find_first!(options = {})
rescue *self.class.expected_errors
end

#find_first!(options = {}) ⇒ Object



42
43
44
# File 'lib/horza/adapters/abstract_adapter.rb', line 42

def find_first!(options = {})
  not_implemented_error
end

#get(options = {}) ⇒ Object



28
29
30
31
# File 'lib/horza/adapters/abstract_adapter.rb', line 28

def get(options = {})
  get!(options = {})
rescue *self.class.expected_errors
end

#get!(options = {}) ⇒ Object



33
34
35
# File 'lib/horza/adapters/abstract_adapter.rb', line 33

def get!(options = {})
  not_implemented_error
end

#to_hashObject



58
59
60
# File 'lib/horza/adapters/abstract_adapter.rb', line 58

def to_hash
  not_implemented_error
end