Sha256: fd006aa9d5bc12601674d01d235d3f3972db429a43f284f8f62e088f90018ec5

Contents?: true

Size: 870 Bytes

Versions: 2

Compression:

Stored size: 870 Bytes

Contents

module Fastbill
  module Automatic
    module Services
      module Update
        module ClassMethods

          def update_attributes(id, attributes)
            id_attribute = "#{self.class.name.split("::").last.downcase}_id".to_sym
            attributes[id_attribute] = id
            response = Fastbill::Automatic.request("#{self.name.split("::").last.downcase}.update", attributes)
            true
          end
        end

        def self.included(base)
          base.extend(ClassMethods)
        end

        def update_attributes(attributes)
          id_attribute = "#{self.class.name.split("::").last.downcase}_id".to_sym
          attributes[id_attribute] = self.send(id_attribute)
          response = Fastbill::Automatic.request("#{self.class.name.split("::").last.downcase}.update", attributes)
          true
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
fastbill-automatic-0.0.4 lib/fastbill-automatic/services/update.rb
fastbill-automatic-0.0.3 lib/fastbill-automatic/services/update.rb