class SimplestStatus::StatusCollection
Constants
- NullStatus
Public Instance Methods
[](status_name)
click to toggle source
# File lib/simplest_status/status_collection.rb, line 13 def [](status_name) status_for(status_name).value end
Also aliased as: value_for
add(status, value = self.size)
click to toggle source
# File lib/simplest_status/status_collection.rb, line 22 def add(status, value = self.size) self.merge!(status => value) end
configure_for(model)
click to toggle source
# File lib/simplest_status/status_collection.rb, line 34 def configure_for(model) tap { ModelMethods.new(model, self).add } end
each() { |status| ... }
click to toggle source
Calls superclass method
# File lib/simplest_status/status_collection.rb, line 7 def each super do |status| yield Status.new(status) end end
for_select()
click to toggle source
# File lib/simplest_status/status_collection.rb, line 30 def for_select map(&:for_select) end
label_for(value)
click to toggle source
# File lib/simplest_status/status_collection.rb, line 26 def label_for(value) status_for(value).label end
model_accessor()
click to toggle source
# File lib/simplest_status/status_collection.rb, line 42 def model_accessor status_name.to_s.pluralize end
status_for(input)
click to toggle source
# File lib/simplest_status/status_collection.rb, line 18 def status_for(input) find { |status| status.matches?(input) } || NullStatus.new end
status_name()
click to toggle source
# File lib/simplest_status/status_collection.rb, line 38 def status_name default end