Sha256: 8d24b985a72db89ddb3ec0311e58fb5c73124fb81e5b9ceed7a789ad7c8ab4b3

Contents?: true

Size: 1.09 KB

Versions: 4

Compression:

Stored size: 1.09 KB

Contents

# -*- encoding : utf-8 -*-
module RademadeAdmin
  module Model
    class Info
      class Relation

        attr_reader :name, :from, :to, :getter, :setter, :type, :foreign_key, :sortable_field

        def has_many?
          @has_many
        end

        def many?
          @many
        end

        def sortable?
          @sortable
        end

        def related_entities(ids)
          RademadeAdmin::Model::Graph.instance.model_info(to).query_adapter.find(ids)
        end

        protected

        # Initialization for Relation info
        #
        # Required options in Hash :name, :from, :to, :setter, :has_many
        # @param opt [Hash]
        #
        def initialize(opt = {})
          @name = opt[:name]
          @from = opt[:from]
          @to = opt[:to]
          @getter = opt[:getter]
          @setter = opt[:setter]
          @type = opt[:type]
          @has_many = opt[:has_many]
          @many = opt[:many]
          @foreign_key = opt[:foreign_key]
          @sortable = opt[:sortable]
          @sortable_field = opt[:sortable_field]
        end

      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rademade_admin-0.1.3 lib/rademade_admin/model/info/relation.rb
rademade_admin-0.1.2 lib/rademade_admin/model/info/relation.rb
rademade_admin-0.1.1 lib/rademade_admin/model/info/relation.rb
rademade_admin-0.1.0 lib/rademade_admin/model/info/relation.rb