Class: HasStates::Configuration::ModelConfiguration
- Inherits:
-
Object
- Object
- HasStates::Configuration::ModelConfiguration
- Defined in:
- lib/has_states/configuration/model_configuration.rb
Instance Attribute Summary collapse
-
#model_class ⇒ Object
readonly
Returns the value of attribute model_class.
-
#state_types ⇒ Object
readonly
Returns the value of attribute state_types.
Instance Method Summary collapse
-
#initialize(model_class) ⇒ ModelConfiguration
constructor
A new instance of ModelConfiguration.
- #state_type(name) {|type| ... } ⇒ Object
Constructor Details
#initialize(model_class) ⇒ ModelConfiguration
Returns a new instance of ModelConfiguration.
8 9 10 11 |
# File 'lib/has_states/configuration/model_configuration.rb', line 8 def initialize(model_class) @model_class = model_class @state_types = {} end |
Instance Attribute Details
#model_class ⇒ Object (readonly)
Returns the value of attribute model_class.
6 7 8 |
# File 'lib/has_states/configuration/model_configuration.rb', line 6 def model_class @model_class end |
#state_types ⇒ Object (readonly)
Returns the value of attribute state_types.
6 7 8 |
# File 'lib/has_states/configuration/model_configuration.rb', line 6 def state_types @state_types end |
Instance Method Details
#state_type(name) {|type| ... } ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/has_states/configuration/model_configuration.rb', line 13 def state_type(name) type = StateTypeConfiguration.new(name) yield(type) if block_given? @state_types[name.to_s] = type # HasStates::State model method generators generate_state_type_scope(name) generate_status_predicates(type.statuses) # Included model method generators generate_state_type_queries(name) generate_state_type_status_predicates(name, type.statuses) end |