Class: Netzke::Basepack::AttrConfig
- Inherits:
-
ActiveSupport::OrderedOptions
- Object
- ActiveSupport::OrderedOptions
- Netzke::Basepack::AttrConfig
show all
- Defined in:
- lib/netzke/basepack/attr_config.rb
Overview
Base for FieldConfig and ColumnConfig
Instance Method Summary
collapse
Constructor Details
#initialize(c, model_adapter) ⇒ AttrConfig
Returns a new instance of AttrConfig.
5
6
7
8
9
10
11
|
# File 'lib/netzke/basepack/attr_config.rb', line 5
def initialize(c, model_adapter)
c = {name: c.to_s} if c.is_a?(Symbol) || c.is_a?(String)
c[:name] = c[:name].to_s
self.replace(c)
@model_adapter = model_adapter
end
|
Instance Method Details
#association? ⇒ Boolean
17
18
19
|
# File 'lib/netzke/basepack/attr_config.rb', line 17
def association?
@model_adapter.association_attr?(self)
end
|
#primary? ⇒ Boolean
13
14
15
|
# File 'lib/netzke/basepack/attr_config.rb', line 13
def primary?
@model_adapter.primary_key_attr?(self)
end
|
#set_defaults ⇒ Object
21
22
23
|
# File 'lib/netzke/basepack/attr_config.rb', line 21
def set_defaults
set_read_only if read_only.nil?
end
|
#set_read_only ⇒ Object
25
26
27
28
29
30
|
# File 'lib/netzke/basepack/attr_config.rb', line 25
def set_read_only
self.read_only = primary? ||
!responded_to_by_model? &&
!association?
self.delete(:read_only) if read_only == false
end
|