Class: SwaggerApi::Actions
- Inherits:
-
Object
- Object
- SwaggerApi::Actions
- Includes:
- ActiveAttr::Model
- Defined in:
- lib/swagger_api/actions.rb
Instance Attribute Summary collapse
-
#controller ⇒ Object
Returns the value of attribute controller.
Instance Method Summary collapse
- #all! ⇒ Object
- #controller_actions ⇒ Object
- #defined_actions ⇒ Object
- #except_actions ⇒ Object
- #only_actions ⇒ Object
- #restful_actions ⇒ Object
- #validate_actions ⇒ Object
Instance Attribute Details
#controller ⇒ Object
Returns the value of attribute controller.
8 9 10 |
# File 'lib/swagger_api/actions.rb', line 8 def controller @controller end |
Instance Method Details
#all! ⇒ Object
11 12 13 14 15 |
# File 'lib/swagger_api/actions.rb', line 11 def all! raise self.errors. unless self.valid? return only_actions unless only_actions.blank? defined_actions end |
#controller_actions ⇒ Object
21 22 23 24 |
# File 'lib/swagger_api/actions.rb', line 21 def controller_actions return [] unless controller.actions.is_a? Array controller.actions end |
#defined_actions ⇒ Object
17 18 19 |
# File 'lib/swagger_api/actions.rb', line 17 def defined_actions (restful_actions + controller_actions) - except_actions end |
#except_actions ⇒ Object
30 31 32 |
# File 'lib/swagger_api/actions.rb', line 30 def except_actions controller.actions.try(:except) || [] end |
#only_actions ⇒ Object
26 27 28 |
# File 'lib/swagger_api/actions.rb', line 26 def only_actions controller.actions.try(:only) || [] end |
#restful_actions ⇒ Object
34 35 36 |
# File 'lib/swagger_api/actions.rb', line 34 def restful_actions %w(index show create update delete) end |
#validate_actions ⇒ Object
38 39 40 41 |
# File 'lib/swagger_api/actions.rb', line 38 def validate_actions errors.add(:base, "`actions` must include at least one of #{restful_actions}") if restful_actions.blank? errors.add(:base, "`actions` can only include one of #{restful_actions}. #{(defined_actions - restful_actions)} are not allowed") unless (defined_actions - restful_actions).blank? end |