Sha256: e512159a223c639f4f06ae3ae3e73bca229da10acb3eb0fdfb4f3ba14c28122e

Contents?: true

Size: 688 Bytes

Versions: 1

Compression:

Stored size: 688 Bytes

Contents

module CanBe
  class Config
    DEFAULT_CAN_BE_FIELD = :can_be_type

    attr_reader :types

    def field_name
      @field_name || CanBe::Config::DEFAULT_CAN_BE_FIELD
    end

    def types=(types)
      @types = types.map(&:to_s)
    end

    def default_type
      @default_type || @types.first
    end

    def parse_options(options = {})
      @default_type = options[:default_type].to_s
      @field_name = options[:field_name]
    end

    def details
      @details ||= {}
    end

    def self.add_detail_model(klass, can_be_class, can_be_type)
      config = can_be_class.to_s.camelize.constantize.can_be_config
      config.details[can_be_type] = klass.name
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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