Sha256: 93e46617983ba46d0ec6a2cbea70d32e63ce99b03d2072bdc5794e0ac735fe6f

Contents?: true

Size: 864 Bytes

Versions: 4

Compression:

Stored size: 864 Bytes

Contents

require 'acts_as_span/span_instance/validations'
require 'acts_as_span/span_instance/status'

require 'active_support/core_ext/module/delegation'

module ActsAsSpan
  class SpanInstance
    include ActsAsSpan::SpanInstance::Validations
    include ActsAsSpan::SpanInstance::Status

    delegate :start_field,
             :end_field,
             :exclude_end, to: :@acts_as_span_definition

    delegate :new_record?, to: :span_model

    attr_reader :name, :span_model, :acts_as_span_definition

    def initialize(name, span_model, acts_as_span_definition)
      @name = name
      @span_model = span_model
      @acts_as_span_definition = acts_as_span_definition
    end

    def span_klass
      @span_klass ||= span_model.class
    end

    def start_date
      span_model[start_field]
    end

    def end_date
      span_model[end_field]
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
acts_as_span-1.1.1 lib/acts_as_span/span_instance.rb
acts_as_span-1.1.0 lib/acts_as_span/span_instance.rb
acts_as_span-1.0.0 lib/acts_as_span/span_instance.rb
acts_as_span-0.0.6 lib/acts_as_span/span_instance.rb