Module: SteelWheel::Shortcuts
- Included in:
- Handler
- Defined in:
- lib/steel_wheel/shortcuts.rb
Overview
Provides shortcuts methods for handlers
Class Method Summary collapse
Instance Method Summary collapse
- #depends_on(*attrs, validate_provided: true) ⇒ Object
- #finder(name, scope, validate_existence: false) ⇒ Object
- #verify(*attrs, valid: true) ⇒ Object
Class Method Details
.included(base) ⇒ Object
6 7 8 |
# File 'lib/steel_wheel/shortcuts.rb', line 6 def self.included(base) base.extend(self) end |
Instance Method Details
#depends_on(*attrs, validate_provided: true) ⇒ Object
10 11 12 13 14 |
# File 'lib/steel_wheel/shortcuts.rb', line 10 def depends_on(*attrs, validate_provided: true) attr_accessor(*attrs) validates(*attrs, 'steel_wheel/query/dependency': validate_provided) end |
#finder(name, scope, validate_existence: false) ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/steel_wheel/shortcuts.rb', line 20 def finder(name, scope, validate_existence: false) define_method(name) do instance_exec(&scope) end memoize name validates name, 'steel_wheel/query/exists': validate_existence end |
#verify(*attrs, valid: true) ⇒ Object
16 17 18 |
# File 'lib/steel_wheel/shortcuts.rb', line 16 def verify(*attrs, valid: true) validates(*attrs, 'steel_wheel/query/verify': valid) end |