Class: ActiveScaffold::DataStructures::NestedInfo

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

Direct Known Subclasses

NestedInfoAssociation, NestedInfoScope

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(model, params) ⇒ NestedInfo

Returns a new instance of NestedInfo.



18
19
20
21
# File 'lib/active_scaffold/data_structures/nested_info.rb', line 18

def initialize(model, params)
  @parent_scaffold = "#{params[:parent_scaffold].to_s.camelize}Controller".constantize
  @parent_model = @parent_scaffold.active_scaffold_config.model
end

Instance Attribute Details

#associationObject

Returns the value of attribute association.



16
17
18
# File 'lib/active_scaffold/data_structures/nested_info.rb', line 16

def association
  @association
end

#child_associationObject

Returns the value of attribute child_association.



16
17
18
# File 'lib/active_scaffold/data_structures/nested_info.rb', line 16

def child_association
  @child_association
end

#constrained_fieldsObject

Returns the value of attribute constrained_fields.



16
17
18
# File 'lib/active_scaffold/data_structures/nested_info.rb', line 16

def constrained_fields
  @constrained_fields
end

#param_nameObject

Returns the value of attribute param_name.



16
17
18
# File 'lib/active_scaffold/data_structures/nested_info.rb', line 16

def param_name
  @param_name
end

#parent_idObject

Returns the value of attribute parent_id.



16
17
18
# File 'lib/active_scaffold/data_structures/nested_info.rb', line 16

def parent_id
  @parent_id
end

#parent_modelObject

Returns the value of attribute parent_model.



16
17
18
# File 'lib/active_scaffold/data_structures/nested_info.rb', line 16

def parent_model
  @parent_model
end

#parent_scaffoldObject

Returns the value of attribute parent_scaffold.



16
17
18
# File 'lib/active_scaffold/data_structures/nested_info.rb', line 16

def parent_scaffold
  @parent_scaffold
end

#scopeObject

Returns the value of attribute scope.



16
17
18
# File 'lib/active_scaffold/data_structures/nested_info.rb', line 16

def scope
  @scope
end

Class Method Details

.get(model, params) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
# File 'lib/active_scaffold/data_structures/nested_info.rb', line 3

def self.get(model, params)
  nested_info = {}
  begin
    unless params[:association].nil?
      ActiveScaffold::DataStructures::NestedInfoAssociation.new(model, params)
    else
      ActiveScaffold::DataStructures::NestedInfoScope.new(model, params)
    end
  rescue ActiveScaffold::ControllerNotFound
    nil
  end
end

Instance Method Details

#belongs_to?Boolean

Returns:

  • (Boolean)


41
42
43
# File 'lib/active_scaffold/data_structures/nested_info.rb', line 41

def belongs_to?
  false
end

#habtm?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/active_scaffold/data_structures/nested_info.rb', line 33

def habtm?
  false 
end

#has_many?Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/active_scaffold/data_structures/nested_info.rb', line 37

def has_many?
  false
end

#has_one?Boolean

Returns:

  • (Boolean)


45
46
47
# File 'lib/active_scaffold/data_structures/nested_info.rb', line 45

def has_one?
  false
end

#new_instance?Boolean

Returns:

  • (Boolean)


27
28
29
30
31
# File 'lib/active_scaffold/data_structures/nested_info.rb', line 27

def new_instance?
  result = @new_instance.nil?
  @new_instance = false
  result
end

#plural_association?Boolean

Returns:

  • (Boolean)


53
54
55
# File 'lib/active_scaffold/data_structures/nested_info.rb', line 53

def plural_association?
  has_many? || habtm?
end

#readonly?Boolean

Returns:

  • (Boolean)


65
66
67
# File 'lib/active_scaffold/data_structures/nested_info.rb', line 65

def readonly?
  false
end

#readonly_through_association?(columns) ⇒ Boolean

Returns:

  • (Boolean)


57
58
59
# File 'lib/active_scaffold/data_structures/nested_info.rb', line 57

def readonly_through_association?(columns)
  false
end

#singular_association?Boolean

Returns:

  • (Boolean)


49
50
51
# File 'lib/active_scaffold/data_structures/nested_info.rb', line 49

def singular_association?
  belongs_to? || has_one?
end

#sorted?Boolean

Returns:

  • (Boolean)


69
70
71
# File 'lib/active_scaffold/data_structures/nested_info.rb', line 69

def sorted?
  false
end

#through_association?Boolean

Returns:

  • (Boolean)


61
62
63
# File 'lib/active_scaffold/data_structures/nested_info.rb', line 61

def through_association?
  false
end

#to_paramsObject



23
24
25
# File 'lib/active_scaffold/data_structures/nested_info.rb', line 23

def to_params
  {:parent_scaffold => parent_scaffold.controller_path}
end