Class: ActiveAdminAssociations::AssociationConfig
- Inherits:
-
Object
- Object
- ActiveAdminAssociations::AssociationConfig
- Includes:
- Enumerable
- Defined in:
- lib/active_admin_associations/association_config.rb
Defined Under Namespace
Classes: Association
Instance Attribute Summary collapse
-
#association_configs ⇒ Object
readonly
Returns the value of attribute association_configs.
Instance Method Summary collapse
- #[](association_name) ⇒ Object
- #association(name, fields = [], &block) ⇒ Object
- #associations(*names) ⇒ Object
- #blank? ⇒ Boolean
-
#initialize(&block) ⇒ AssociationConfig
constructor
A new instance of AssociationConfig.
Constructor Details
#initialize(&block) ⇒ AssociationConfig
Returns a new instance of AssociationConfig.
27 28 29 30 |
# File 'lib/active_admin_associations/association_config.rb', line 27 def initialize(&block) @association_configs = [] instance_exec(&block) end |
Instance Attribute Details
#association_configs ⇒ Object (readonly)
Returns the value of attribute association_configs.
24 25 26 |
# File 'lib/active_admin_associations/association_config.rb', line 24 def association_configs @association_configs end |
Instance Method Details
#[](association_name) ⇒ Object
36 37 38 |
# File 'lib/active_admin_associations/association_config.rb', line 36 def [](association_name) @association_configs.detect {|a| a.name == association_name.to_sym } end |
#association(name, fields = [], &block) ⇒ Object
40 41 42 |
# File 'lib/active_admin_associations/association_config.rb', line 40 def association(name, fields = [], &block) @association_configs << Association.new(name, fields, &block) end |
#associations(*names) ⇒ Object
44 45 46 47 48 |
# File 'lib/active_admin_associations/association_config.rb', line 44 def associations(*names) names.each do |name| @association_configs << Association.new(name) end end |
#blank? ⇒ Boolean
32 33 34 |
# File 'lib/active_admin_associations/association_config.rb', line 32 def blank? @association_configs.blank? end |