Class: Eco::API::Common::Loaders::Base

Inherits:
Object
  • Object
show all
Extended by:
ClassHelpers
Defined in:
lib/eco/api/common/loaders/base.rb

Direct Known Subclasses

CaseBase

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ClassHelpers

class_resolver, descendants, descendants?, inheritable_attrs, inheritable_class_vars, inherited, instance_variable_name, new_class, resolve_class, to_constant

Constructor Details

#initializeBase

Note:
  • this method should implement the loading logics for the given Children class.

This method will be called when the BaseLoader is created



28
29
30
# File 'lib/eco/api/common/loaders/base.rb', line 28

def initialize
  raise "You should implement this method"
end

Class Method Details

.<=>(other) ⇒ Object

Sort order



10
11
12
# File 'lib/eco/api/common/loaders/base.rb', line 10

def <=>(other)
  created_at <=> other.created_at
end

.created_atObject

Class creation timestamp, to be able to load them in the order they were declared.



20
21
22
# File 'lib/eco/api/common/loaders/base.rb', line 20

def created_at
  @created_at ||= Time.now
end

.set_created_at!Object

If still not set, it sets the created_at class timestamp.



15
16
17
# File 'lib/eco/api/common/loaders/base.rb', line 15

def set_created_at!
  @created_at = Time.now unless @created_at
end

Instance Method Details

#nameObject



32
33
34
# File 'lib/eco/api/common/loaders/base.rb', line 32

def name
  self.class.name
end