Class: StatusManager::StatusStore
- Inherits:
-
Object
- Object
- StatusManager::StatusStore
- Defined in:
- lib/status-manager/status_store.rb
Instance Attribute Summary collapse
-
#attribute_name ⇒ Object
Returns the value of attribute attribute_name.
-
#group_statuses ⇒ Object
Returns the value of attribute group_statuses.
-
#status_sets ⇒ Object
Returns the value of attribute status_sets.
Instance Method Summary collapse
- #add_group_status(group_status_name, statuses) ⇒ Object
- #get_group_status_sets(group_status_name) ⇒ Object
- #group_status?(group_status) ⇒ Boolean
-
#initialize(attribute_name, status_sets = nil) ⇒ StatusStore
constructor
A new instance of StatusStore.
- #status(value) ⇒ Object
- #status?(status) ⇒ Boolean
- #statuses ⇒ Object
- #value(status) ⇒ Object
- #values ⇒ Object
Constructor Details
#initialize(attribute_name, status_sets = nil) ⇒ StatusStore
Returns a new instance of StatusStore.
21 22 23 24 25 |
# File 'lib/status-manager/status_store.rb', line 21 def initialize(attribute_name, status_sets=nil ) @attribute_name = attribute_name @status_sets = status_sets || {} @group_statuses = {} end |
Instance Attribute Details
#attribute_name ⇒ Object
Returns the value of attribute attribute_name.
19 20 21 |
# File 'lib/status-manager/status_store.rb', line 19 def attribute_name @attribute_name end |
#group_statuses ⇒ Object
Returns the value of attribute group_statuses.
19 20 21 |
# File 'lib/status-manager/status_store.rb', line 19 def group_statuses @group_statuses end |
#status_sets ⇒ Object
Returns the value of attribute status_sets.
19 20 21 |
# File 'lib/status-manager/status_store.rb', line 19 def status_sets @status_sets end |
Instance Method Details
#add_group_status(group_status_name, statuses) ⇒ Object
51 52 53 |
# File 'lib/status-manager/status_store.rb', line 51 def add_group_status(group_status_name, statuses) @group_statuses.merge!({group_status_name => statuses}) end |
#get_group_status_sets(group_status_name) ⇒ Object
55 56 57 58 59 60 61 |
# File 'lib/status-manager/status_store.rb', line 55 def get_group_status_sets(group_status_name) statuses = {} @group_statuses[group_status_name].each do |status| statuses[status] = self.value(status) end statuses end |
#group_status?(group_status) ⇒ Boolean
31 32 33 |
# File 'lib/status-manager/status_store.rb', line 31 def group_status?(group_status) @group_statuses.key?(group_status) end |
#status(value) ⇒ Object
47 48 49 |
# File 'lib/status-manager/status_store.rb', line 47 def status(value) @status_sets.select{ |status, _value| _value == value}.first[0] end |
#status?(status) ⇒ Boolean
27 28 29 |
# File 'lib/status-manager/status_store.rb', line 27 def status?(status) @status_sets.key?(status) end |
#statuses ⇒ Object
35 36 37 |
# File 'lib/status-manager/status_store.rb', line 35 def statuses @status_sets.keys end |
#value(status) ⇒ Object
43 44 45 |
# File 'lib/status-manager/status_store.rb', line 43 def value(status) @status_sets[status] end |
#values ⇒ Object
39 40 41 |
# File 'lib/status-manager/status_store.rb', line 39 def values @status_sets.values end |