Class: CanBe::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/can_be/config.rb

Constant Summary collapse

DEFAULT_CAN_BE_FIELD =
:can_be_type
DEFAULT_DETAILS_NAME =
:details

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#history_modelObject (readonly)

Returns the value of attribute history_model.



6
7
8
# File 'lib/can_be/config.rb', line 6

def history_model
  @history_model
end

#typesObject

Returns the value of attribute types.



6
7
8
# File 'lib/can_be/config.rb', line 6

def types
  @types
end

Instance Method Details

#add_details_model(can_be_type, model_symbol) ⇒ Object



45
46
47
# File 'lib/can_be/config.rb', line 45

def add_details_model(can_be_type, model_symbol)
  self.details[can_be_type] = model_symbol
end

#default_type(type = nil) ⇒ Object



28
29
30
31
32
33
34
# File 'lib/can_be/config.rb', line 28

def default_type(type = nil)
  if type.nil?
    @default_type || @types.first
  else
    @default_type = type
  end
end

#detailsObject



41
42
43
# File 'lib/can_be/config.rb', line 41

def details
  @details ||= {}
end

#details_name(name = nil) ⇒ Object



16
17
18
19
20
21
22
# File 'lib/can_be/config.rb', line 16

def details_name(name = nil)
  if name.nil?
    @details_name || CanBe::Config::DEFAULT_DETAILS_NAME
  else
    @details_name = name
  end
end

#field_name(name = nil) ⇒ Object



8
9
10
11
12
13
14
# File 'lib/can_be/config.rb', line 8

def field_name(name = nil)
  if name.nil?
    @field_name || CanBe::Config::DEFAULT_CAN_BE_FIELD
  else
    @field_name = name
  end
end

#keep_history_in(history_model) ⇒ Object



49
50
51
# File 'lib/can_be/config.rb', line 49

def keep_history_in(history_model)
  @history_model = history_model
end

#keeps_history?Boolean



53
54
55
# File 'lib/can_be/config.rb', line 53

def keeps_history?
  !@history_model.nil?
end

#parse_options(options = {}) ⇒ Object



36
37
38
39
# File 'lib/can_be/config.rb', line 36

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