Sha256: be7b131cd0849aea4678dadce01bafcb59833b104e2203a7f83c41cc62fc5a71

Contents?: true

Size: 1.18 KB

Versions: 6

Compression:

Stored size: 1.18 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 gallery?
          @is_gallery
        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]
          @is_gallery = opt[:is_gallery]
        end

      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rademade_admin-0.2.2 lib/rademade_admin/model/info/relation.rb
rademade_admin-0.2.1 lib/rademade_admin/model/info/relation.rb
rademade_admin-0.2.0 lib/rademade_admin/model/info/relation.rb
rademade_admin-0.1.6 lib/rademade_admin/model/info/relation.rb
rademade_admin-0.1.5 lib/rademade_admin/model/info/relation.rb
rademade_admin-0.1.4 lib/rademade_admin/model/info/relation.rb