lib/can_be/config.rb in can_be-0.2.1 vs lib/can_be/config.rb in can_be-0.3.0

- old
+ new

@@ -1,21 +1,38 @@ module CanBe class Config DEFAULT_CAN_BE_FIELD = :can_be_type + DEFAULT_DETAILS_NAME = :details - attr_reader :types + attr_reader :types, :history_model - def field_name - @field_name || CanBe::Config::DEFAULT_CAN_BE_FIELD + def field_name(name = nil) + if name.nil? + @field_name || CanBe::Config::DEFAULT_CAN_BE_FIELD + else + @field_name = name + end end + def details_name(name = nil) + if name.nil? + @details_name || CanBe::Config::DEFAULT_DETAILS_NAME + else + @details_name = name + end + end + def types=(types) @types = types.map(&:to_s) end - def default_type - @default_type || @types.first + def default_type(type = nil) + if type.nil? + @default_type || @types.first + else + @default_type = type + end end def parse_options(options = {}) @default_type = options[:default_type].to_s @field_name = options[:field_name] @@ -25,8 +42,16 @@ @details ||= {} end def add_details_model(can_be_type, model_symbol) self.details[can_be_type] = model_symbol + end + + def keep_history_in(history_model) + @history_model = history_model + end + + def keeps_history? + !@history_model.nil? end end end