Sha256: 1d101b3b9c17954b0dc5ea6c04e99dd72a85eee481c3dcc35a415cf370df84ba
Contents?: true
Size: 1.45 KB
Versions: 1
Compression:
Stored size: 1.45 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, :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", 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 end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
active_fields-0.2.0 | lib/active_fields/config.rb |