Module: Resourceful::Model::Findable::InstanceMethods

Defined in:
lib/resourceful/model/findable.rb

Instance Method Summary collapse

Instance Method Details

#destroyObject



66
67
68
69
70
71
72
73
74
75
76
# File 'lib/resourceful/model/findable.rb', line 66

def destroy
  super do |attribute_hash|
    unless new_record?
      self.push_data('delete', \
        "#{self.class.findable_index}/#{self.id}.#{self.class.format}", \
        {:params => self.class.findable_default_opts.merge(push_data_params)}, \
        {} \
      )
    end
  end
end

#push_data_nestingObject



83
84
85
86
# File 'lib/resourceful/model/findable.rb', line 83

def push_data_nesting
  # default, override to customize, set to nil for push data hash style nesting
  self.class.name.demodulize.underscore
end

#push_data_paramsObject



78
79
80
81
# File 'lib/resourceful/model/findable.rb', line 78

def push_data_params
  # override to customize save url params
  {}
end

#saveObject



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/resourceful/model/findable.rb', line 46

def save
  super do |attribute_hash|
    if new_record?
      self.push_data('post', \
        "#{self.class.findable_index}.#{self.class.format}", \
        {:params => self.class.findable_default_opts.merge(push_data_params)}, \
        nested_attr_hash(attribute_hash), \
        self.class.findable_search \
      )
    else
      self.push_data('put', \
        "#{self.class.findable_index}/#{self.id}.#{self.class.format}", \
        {:params => self.class.findable_default_opts.merge(push_data_params)}, \
        nested_attr_hash(attribute_hash), \
        self.class.findable_search \
      )
    end
  end
end