Class: ActiveScaffold::DataStructures::NestedInfoAssociation

Inherits:
NestedInfo show all
Defined in:
lib/active_scaffold/data_structures/nested_info.rb

Instance Attribute Summary

Attributes inherited from NestedInfo

#association, #child_association, #constrained_fields, #parent_id, #parent_model, #parent_scaffold, #scope

Instance Method Summary collapse

Methods inherited from NestedInfo

get, #new_instance?, #parent_scope, #plural_association?, #singular_association?

Constructor Details

#initialize(model, nested_info) ⇒ NestedInfoAssociation

Returns a new instance of NestedInfoAssociation.



86
87
88
89
90
# File 'lib/active_scaffold/data_structures/nested_info.rb', line 86

def initialize(model, nested_info)
  super(model, nested_info)
  @association = parent_model.reflect_on_association(nested_info[:name])
  iterate_model_associations(model)
end

Instance Method Details

#belongs_to?Boolean

Returns:

  • (Boolean)


104
105
106
# File 'lib/active_scaffold/data_structures/nested_info.rb', line 104

def belongs_to?
  association.belongs_to?
end

#default_sortingObject



124
125
126
# File 'lib/active_scaffold/data_structures/nested_info.rb', line 124

def default_sorting
  association.options[:order]
end

#habtm?Boolean

Returns:

  • (Boolean)


100
101
102
# File 'lib/active_scaffold/data_structures/nested_info.rb', line 100

def habtm?
  association.macro == :has_and_belongs_to_many 
end

#has_many?Boolean

Returns:

  • (Boolean)


96
97
98
# File 'lib/active_scaffold/data_structures/nested_info.rb', line 96

def has_many?
  association.macro == :has_many 
end

#has_one?Boolean

Returns:

  • (Boolean)


108
109
110
# File 'lib/active_scaffold/data_structures/nested_info.rb', line 108

def has_one?
  association.macro == :has_one
end

#nameObject



92
93
94
# File 'lib/active_scaffold/data_structures/nested_info.rb', line 92

def name
  self.association.name
end

#readonly?Boolean

Returns:

  • (Boolean)


116
117
118
# File 'lib/active_scaffold/data_structures/nested_info.rb', line 116

def readonly?
  association.options[:readonly]
end

#sorted?Boolean

Returns:

  • (Boolean)


120
121
122
# File 'lib/active_scaffold/data_structures/nested_info.rb', line 120

def sorted?
  association.options.has_key? :order
end

#through_association?Boolean

Returns:

  • (Boolean)


112
113
114
# File 'lib/active_scaffold/data_structures/nested_info.rb', line 112

def through_association?
  association.options[:through]
end

#to_paramsObject



128
129
130
# File 'lib/active_scaffold/data_structures/nested_info.rb', line 128

def to_params
  super.merge(:association => @association.name, :assoc_id => parent_id)
end