Sha256: 07b85c7466eba99154b87db0338ac7f2720df3c2b3d97a2a6f0aea2bdfa88c74

Contents?: true

Size: 706 Bytes

Versions: 2

Compression:

Stored size: 706 Bytes

Contents

module ActiveData
  module Model
    module Associations
      class Association
        attr_reader :name, :klass, :options

        def initialize name, options = {}
          @name, @options = name.to_s, options
          @klass ||= options[:class] || (options[:class_name].to_s.presence || name.to_s.classify).safe_constantize
          raise "Can not determine class for `#{name}` association" unless @klass
        end

        def class_name
          klass.to_s
        end

        def define_accessor klass
          define_reader klass
          define_writer klass
        end

        def define_reader klass
        end

        def define_writer klass
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
active_data-0.3.0 lib/active_data/model/associations/association.rb
active_data-0.2.0 lib/active_data/model/associations/association.rb