Class: ActiveScaffold::DataStructures::NestedInfo
- Defined in:
- lib/active_scaffold/data_structures/nested_info.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#association ⇒ Object
Returns the value of attribute association.
-
#child_association ⇒ Object
Returns the value of attribute child_association.
-
#constrained_fields ⇒ Object
Returns the value of attribute constrained_fields.
-
#parent_id ⇒ Object
Returns the value of attribute parent_id.
-
#parent_model ⇒ Object
Returns the value of attribute parent_model.
-
#parent_scaffold ⇒ Object
Returns the value of attribute parent_scaffold.
-
#scope ⇒ Object
Returns the value of attribute scope.
Class Method Summary collapse
Instance Method Summary collapse
- #belongs_to? ⇒ Boolean
- #habtm? ⇒ Boolean
- #has_one? ⇒ Boolean
-
#initialize(model, session_info) ⇒ NestedInfo
constructor
A new instance of NestedInfo.
- #new_instance? ⇒ Boolean
- #parent_scope ⇒ Object
- #readonly? ⇒ Boolean
- #sorted? ⇒ Boolean
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
#association ⇒ Object
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_association ⇒ Object
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_fields ⇒ Object
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_id ⇒ Object
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_model ⇒ Object
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_scaffold ⇒ Object
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 |
#scope ⇒ Object
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
45 46 47 |
# File 'lib/active_scaffold/data_structures/nested_info.rb', line 45 def belongs_to? false end |
#habtm? ⇒ Boolean
41 42 43 |
# File 'lib/active_scaffold/data_structures/nested_info.rb', line 41 def habtm? false end |
#has_one? ⇒ Boolean
49 50 51 |
# File 'lib/active_scaffold/data_structures/nested_info.rb', line 49 def has_one? false end |
#new_instance? ⇒ 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_scope ⇒ Object
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
53 54 55 |
# File 'lib/active_scaffold/data_structures/nested_info.rb', line 53 def readonly? false end |
#sorted? ⇒ Boolean
57 58 59 |
# File 'lib/active_scaffold/data_structures/nested_info.rb', line 57 def sorted? false end |