module Relaxation::Relaxable::ClassMethods

Public Instance Methods

creatable(*attributes) click to toggle source
# File lib/relaxation/relaxable.rb, line 28
def creatable(*attributes)
  self.create_whitelist = attributes
end
filterable(*attributes) click to toggle source
# File lib/relaxation/relaxable.rb, line 24
def filterable(*attributes)
  self.filter_whitelist = attributes
end
permit_actions(options) click to toggle source
# File lib/relaxation/relaxable.rb, line 48
def permit_actions(options)
  if only = options[:only]
    Array.wrap(only) & PERMITTED
  elsif except = options[:except]
    PERMITTED - Array.wrap(except)
  else
    PERMITTED
  end
end
relax(options = {}) click to toggle source
# File lib/relaxation/relaxable.rb, line 40
def relax(options = {})
  self.scope_method ||= DEFAULT_SCOPE

  permit_actions(options).each do |action|
    define_method(action) { send("_#{action}") }
  end
end
updatable(*attributes) click to toggle source
# File lib/relaxation/relaxable.rb, line 32
def updatable(*attributes)
  self.update_whitelist = attributes
end
use_scope(scope_method) click to toggle source
# File lib/relaxation/relaxable.rb, line 36
def use_scope(scope_method)
  self.scope_method = scope_method
end
writable(*attributes) click to toggle source
# File lib/relaxation/relaxable.rb, line 19
def writable(*attributes)
  creatable(attributes)
  updatable(attributes)
end