class NiftyServices::BaseCrudService
Attributes
record[R]
Public Class Methods
get_whitelist_attributes()
click to toggle source
# File lib/nifty_services/base_crud_service.rb, line 33 def get_whitelist_attributes [] end
new(record, options = {})
click to toggle source
Calls superclass method
# File lib/nifty_services/base_crud_service.rb, line 38 def initialize(record, options = {}) @record = record super(options) end
record_type(record_type, options = {})
click to toggle source
# File lib/nifty_services/base_crud_service.rb, line 7 def record_type(record_type, options = {}) define_method :record_type do record_type end record_alias = options.delete(:alias_name) || record_type.to_s.underscore alias_method record_alias.to_sym, :record end
whitelist_attributes(*attrs)
click to toggle source
# File lib/nifty_services/base_crud_service.rb, line 17 def whitelist_attributes(*attrs) raise "Invalid whitelist attributes(#{attrs}) array" unless attrs.is_a?(Array) attributes = *attrs.flatten.map(&:to_sym) define_method :record_attributes_whitelist do attributes end define_singleton_method :get_whitelist_attributes do attributes end attributes end
Public Instance Methods
changed?()
click to toggle source
# File lib/nifty_services/base_crud_service.rb, line 48 def changed? changed_attributes.any? end
changed_attributes()
click to toggle source
# File lib/nifty_services/base_crud_service.rb, line 44 def changed_attributes [] end
record_allowed_attributes()
click to toggle source
# File lib/nifty_services/base_crud_service.rb, line 64 def record_allowed_attributes filter_hash(record_attributes_hash, record_attributes_whitelist) end
Also aliased as: record_safe_attributes
record_attributes_hash()
click to toggle source
# File lib/nifty_services/base_crud_service.rb, line 56 def record_attributes_hash not_implemented_exception(__method__) end
record_attributes_whitelist()
click to toggle source
# File lib/nifty_services/base_crud_service.rb, line 60 def record_attributes_whitelist not_implemented_exception(__method__) end
record_type()
click to toggle source
# File lib/nifty_services/base_crud_service.rb, line 52 def record_type not_implemented_exception(__method__) end
Private Instance Methods
record_error_key()
click to toggle source
# File lib/nifty_services/base_crud_service.rb, line 71 def record_error_key # very simple and poor way to pluralize string record_type.to_s.underscore + "s" end
valid_record?()
click to toggle source
# File lib/nifty_services/base_crud_service.rb, line 76 def valid_record? valid_object?(@record, record_type) end