Sha256: e068fb5be73907eaed9b23754a771440689c747253a9d4df026f0a0be20f9930

Contents?: true

Size: 765 Bytes

Versions: 2

Compression:

Stored size: 765 Bytes

Contents

require 'active_model'
require 'active_copy/attributes'
require 'active_copy/finders'
require 'active_copy/paths'
require 'active_copy/source'

# Base class for an +ActiveCopy+ model.

module ActiveCopy
  class Base
    include ActiveModel::Model
    include Attributes, Finders, Paths, Source

    attr_accessor :id

    # Serialize comma-separated tags to an array.
    def tags
      attributes[:tags].split(',').map(&:strip)
    end

    class << self
      # New and create are the same thing.
      alias create new
    end

    # Files are persisted when they are present on disk.
    alias persisted? present?

    def method_missing method, *arguments
      super method, *arguments unless attribute? "#{method}"
      attributes[method]
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
active_copy-1.0.0 lib/active_copy/base.rb
active_copy-1.0.0.pre lib/active_copy/base.rb