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



139
140
141
142
143
# File 'lib/smooth_operator/persistence.rb', line 139

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

#destroy_keyObject



135
136
137
# File 'lib/smooth_operator/persistence.rb', line 135

def destroy_key
  get_option :destroy_key, '_destroy'
end

#http_verb_for(method) ⇒ Object



127
128
129
# File 'lib/smooth_operator/persistence.rb', line 127

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

#primary_keyObject



131
132
133
# File 'lib/smooth_operator/persistence.rb', line 131

def primary_key
  get_option :primary_key, 'id'
end