Class: WCC::Data::EnumeratedType
- Inherits:
-
Object
- Object
- WCC::Data::EnumeratedType
show all
- Defined in:
- lib/wcc/data/enumerated_type.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
Returns a new instance of EnumeratedType.
4
5
6
7
8
|
# File 'lib/wcc/data/enumerated_type.rb', line 4
def initialize(args={})
only_attributes(args).each do |key, value|
instance_variable_set("@#{key}", value)
end
end
|
Class Method Details
.[](value) ⇒ Object
10
11
12
|
# File 'lib/wcc/data/enumerated_type.rb', line 10
def self.[](value)
all.find { |record| record.matches?(value) }
end
|
.all ⇒ Object
26
27
28
|
# File 'lib/wcc/data/enumerated_type.rb', line 26
def self.all
@all ||= db.collect { |data| new(data) }
end
|
.db ⇒ Object
20
21
22
23
24
|
# File 'lib/wcc/data/enumerated_type.rb', line 20
def self.db
raise NotImplementedError,
"The ::db class method should be defined in subclasses as an array " \
"of hashes containing data for each record."
end
|
.reset ⇒ Object
30
31
32
|
# File 'lib/wcc/data/enumerated_type.rb', line 30
def self.reset
@all = nil
end
|
Instance Method Details
#matches?(value) ⇒ Boolean
14
15
16
17
18
|
# File 'lib/wcc/data/enumerated_type.rb', line 14
def matches?(value)
raise NotImplementedError,
"The #matches? method should be defined in subclasses and return " \
"true if the argument matches this record and false otherwise."
end
|