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, session_info) ⇒ NestedInfo

Returns a new instance of NestedInfo.



25
26
27
28
29
# File 'lib/active_scaffold/data_structures/nested_info.rb', line 25

def initialize(model, session_info)
  @parent_model = session_info[:parent_model]
  @parent_id = session_info[:parent_id]
  @parent_scaffold = session_info[:parent_scaffold]
end

Instance Attribute Details

#associationObject

Returns the value of attribute association.



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

def association
  @association
end

#child_associationObject

Returns the value of attribute child_association.



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

def child_association
  @child_association
end

#constrained_fieldsObject

Returns the value of attribute constrained_fields.



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

def constrained_fields
  @constrained_fields
end

#parent_idObject

Returns the value of attribute parent_id.



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

def parent_id
  @parent_id
end

#parent_modelObject

Returns the value of attribute parent_model.



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

def parent_model
  @parent_model
end

#parent_scaffoldObject

Returns the value of attribute parent_scaffold.



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

def parent_scaffold
  @parent_scaffold
end

#scopeObject

Returns the value of attribute scope.



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

def scope
  @scope
end

Class Method Details

.get(model, session_storage) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/active_scaffold/data_structures/nested_info.rb', line 3

def self.get(model, session_storage)
  if session_storage[:nested].nil? 
    nil
  else
    session_info = session_storage[:nested].clone
    begin
      session_info[:parent_scaffold] = "#{session_info[:parent_scaffold].to_s.camelize}Controller".constantize
      session_info[:parent_model] = session_info[:parent_scaffold].active_scaffold_config.model
      session_info[:association] = session_info[:parent_model].reflect_on_association(session_info[:name])
      unless session_info[:association].nil?
        ActiveScaffold::DataStructures::NestedInfoAssociation.new(model, session_info)
      else
        ActiveScaffold::DataStructures::NestedInfoScope.new(model, session_info)
      end
    rescue ActiveScaffold::ControllerNotFound
      nil
    end
  end
end

Instance Method Details

#belongs_to?Boolean

Returns:

  • (Boolean)


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

def belongs_to?
  false
end

#habtm?Boolean

Returns:

  • (Boolean)


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

def habtm?
  false 
end

#has_one?Boolean

Returns:

  • (Boolean)


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

def has_one?
  false
end

#new_instance?Boolean

Returns:

  • (Boolean)


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

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

#parent_scopeObject



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

def parent_scope
  parent_model.find(parent_id)
end

#readonly?Boolean

Returns:

  • (Boolean)


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

def readonly?
  false
end

#sorted?Boolean

Returns:

  • (Boolean)


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

def sorted?
  false
end