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
- #create(attributes = nil, relative_path = nil, data = {}, options = {}) ⇒ Object
- #destroy_key ⇒ Object
- #http_verb_for(method) ⇒ Object
- #primary_key ⇒ Object
Instance Method Details
#create(attributes = nil, relative_path = nil, data = {}, options = {}) ⇒ Object
151 152 153 154 155 |
# File 'lib/smooth_operator/persistence.rb', line 151 def create(attributes = nil, relative_path = nil, data = {}, = {}) new(attributes).tap do |object| object.save(relative_path, data, ) end end |
#destroy_key ⇒ Object
147 148 149 |
# File 'lib/smooth_operator/persistence.rb', line 147 def destroy_key get_option :destroy_key, '_destroy' end |
#http_verb_for(method) ⇒ Object
139 140 141 |
# File 'lib/smooth_operator/persistence.rb', line 139 def http_verb_for(method) get_option "#{method}_http_verb".to_sym, METHODS_VS_HTTP_VERBS[method] end |
#primary_key ⇒ Object
143 144 145 |
# File 'lib/smooth_operator/persistence.rb', line 143 def primary_key get_option :primary_key, 'id' end |