Sha256: 42bfa435f152ea38a3c6586c654b7a0bf5c8f539ed3471abf869fc24ea988eb8
Contents?: true
Size: 1.67 KB
Versions: 2
Compression:
Stored size: 1.67 KB
Contents
# frozen_string_literal: true module ActiveFields class Config DEFAULT_FIELD_BASE_CLASS_NAME = "ActiveFields::Field::Base" DEFAULT_VALUE_CLASS_NAME = "ActiveFields::Value" include Singleton attr_accessor :field_base_class_name, :value_class_name attr_reader :fields def initialize @field_base_class_name = DEFAULT_FIELD_BASE_CLASS_NAME @value_class_name = DEFAULT_VALUE_CLASS_NAME @fields = { boolean: "ActiveFields::Field::Boolean", date: "ActiveFields::Field::Date", date_array: "ActiveFields::Field::DateArray", datetime: "ActiveFields::Field::DateTime", datetime_array: "ActiveFields::Field::DateTimeArray", decimal: "ActiveFields::Field::Decimal", decimal_array: "ActiveFields::Field::DecimalArray", enum: "ActiveFields::Field::Enum", enum_array: "ActiveFields::Field::EnumArray", integer: "ActiveFields::Field::Integer", integer_array: "ActiveFields::Field::IntegerArray", text: "ActiveFields::Field::Text", text_array: "ActiveFields::Field::TextArray", } end def field_base_class @field_base_class ||= field_base_class_name.constantize end def value_class @value_class ||= value_class_name.constantize end def field_base_class_changed? field_base_class_name != DEFAULT_FIELD_BASE_CLASS_NAME end def value_class_changed? value_class_name != DEFAULT_VALUE_CLASS_NAME end def register_field(type_name, class_name) @fields[type_name.to_sym] = class_name end def type_names fields.keys end def type_class_names fields.values end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
active_fields-1.1.0 | lib/active_fields/config.rb |
active_fields-1.0.0 | lib/active_fields/config.rb |