Sha256: a5810a1c2232e5a636d959e22ec5a9e5a790ca7b71f0c1d70840b4534a5d9790

Contents?: true

Size: 705 Bytes

Versions: 1

Compression:

Stored size: 705 Bytes

Contents

require 'active_support/concern'

module CanBe
  module ModelExtensions
    extend ActiveSupport::Concern

    module ClassMethods
      def can_be_config
        @can_be_config ||= CanBe::Config.new
      end

      def can_be(*types)
        if types.last.is_a?(Hash)
          options = types.last
          types.delete types.last
        end

        can_be_config.types = types
        can_be_config.parse_options options if options

        CanBe::Builder::CanBe.build(self)
      end

      def can_be_detail(can_be_model, can_be_type)
        CanBe::Config.add_detail_model self, can_be_model, can_be_type
        CanBe::Builder::CanBeDetail.build(self, can_be_model)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
can_be-0.2.0 lib/can_be/model_extensions.rb