Module: Relaxation::Relaxable::ClassMethods
- Defined in:
- lib/relaxation/relaxable.rb
Instance Method Summary collapse
- #creatable(*attributes) ⇒ Object
- #filterable(*attributes) ⇒ Object
- #permit_actions(options) ⇒ Object
- #relax(options = {}) ⇒ Object
- #updatable(*attributes) ⇒ Object
- #use_scope(scope_method) ⇒ Object
- #writable(*attributes) ⇒ Object
Instance Method Details
#creatable(*attributes) ⇒ Object
28 29 30 |
# File 'lib/relaxation/relaxable.rb', line 28 def creatable(*attributes) self.create_whitelist = attributes end |
#filterable(*attributes) ⇒ Object
24 25 26 |
# File 'lib/relaxation/relaxable.rb', line 24 def filterable(*attributes) self.filter_whitelist = attributes end |
#permit_actions(options) ⇒ Object
48 49 50 51 52 53 54 55 56 |
# File 'lib/relaxation/relaxable.rb', line 48 def permit_actions() if only = [:only] Array.wrap(only) & PERMITTED elsif except = [:except] PERMITTED - Array.wrap(except) else PERMITTED end end |
#relax(options = {}) ⇒ Object
40 41 42 43 44 45 46 |
# File 'lib/relaxation/relaxable.rb', line 40 def relax( = {}) self.scope_method ||= DEFAULT_SCOPE permit_actions().each do |action| define_method(action) { send("_#{action}") } end end |
#updatable(*attributes) ⇒ Object
32 33 34 |
# File 'lib/relaxation/relaxable.rb', line 32 def updatable(*attributes) self.update_whitelist = attributes end |
#use_scope(scope_method) ⇒ Object
36 37 38 |
# File 'lib/relaxation/relaxable.rb', line 36 def use_scope(scope_method) self.scope_method = scope_method end |
#writable(*attributes) ⇒ Object
19 20 21 22 |
# File 'lib/relaxation/relaxable.rb', line 19 def writable(*attributes) creatable(attributes) updatable(attributes) end |