Module: SmoothOperator::Persistence::ClassMethods

Defined in:
lib/smooth_operator/persistence.rb

Constant Summary collapse

METHODS_VS_HTTP_VERBS =
{ reload: :get, create: :post, update: :put, destroy: :delete }

Instance Method Summary collapse

Instance Method Details

#create(attributes = nil, relative_path = nil, data = {}, options = {}) ⇒ Object



141
142
143
144
145
# File 'lib/smooth_operator/persistence.rb', line 141

def create(attributes = nil, relative_path = nil, data = {}, options = {})
  new(attributes).tap do |object|
    object.save(relative_path, data, options)
  end
end

#destroy_keyObject



137
138
139
# File 'lib/smooth_operator/persistence.rb', line 137

def destroy_key
  get_option :destroy_key, '_destroy'
end

#http_verb_for(method) ⇒ Object



129
130
131
# File 'lib/smooth_operator/persistence.rb', line 129

def http_verb_for(method)
  get_option "#{method}_http_verb".to_sym, METHODS_VS_HTTP_VERBS[method]
end

#primary_keyObject



133
134
135
# File 'lib/smooth_operator/persistence.rb', line 133

def primary_key
  get_option :primary_key, 'id'
end