Sha256: 4848c76670ccfc890160033a9e1897217bbe52974fc337a17dcc927452c6e591

Contents?: true

Size: 570 Bytes

Versions: 4

Compression:

Stored size: 570 Bytes

Contents

module Printfection
  class Resource < Hashie::Trash
    include Hashie::Extensions::IndifferentAccess
    include Hashie::Extensions::Coercion

    property :object

    attr_accessor :relation

    def initialize(*args)
      super
      @_old = self.dup
    end

    def uri
      base = self.relation.nil? ? self.class.uri : self.relation.uri
      Util.join_uri(base, self.id)
    end

    def changes
      keys.inject({}) do |diff, key|
        unless self[key] == @_old[key]
          diff[key] = self[key]
        end
        diff
      end
    end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
printfection-1.0.3 lib/printfection/resource.rb
printfection-1.0.2 lib/printfection/resource.rb
printfection-1.0.1 lib/printfection/resource.rb
printfection-1.0.0 lib/printfection/resource.rb