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.



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

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.



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

def association
  @association
end

#child_associationObject

Returns the value of attribute child_association.



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

def child_association
  @child_association
end

#constrained_fieldsObject

Returns the value of attribute constrained_fields.



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

def constrained_fields
  @constrained_fields
end

#param_nameObject

Returns the value of attribute param_name.



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

def param_name
  @param_name
end

#parent_idObject

Returns the value of attribute parent_id.



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

def parent_id
  @parent_id
end

#parent_modelObject

Returns the value of attribute parent_model.



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

def parent_model
  @parent_model
end

#parent_scaffoldObject

Returns the value of attribute parent_scaffold.



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

def parent_scaffold
  @parent_scaffold
end

#scopeObject

Returns the value of attribute scope.



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

def scope
  @scope
end

Class Method Details

.get(model, params) ⇒ Object



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

def self.get(model, params)
  if params[:association].nil?
    ActiveScaffold::DataStructures::NestedInfoScope.new(model, params)
  else
    ActiveScaffold::DataStructures::NestedInfoAssociation.new(model, params)
  end
rescue ActiveScaffold::ControllerNotFound
  nil
end

Instance Method Details

#belongs_to?Boolean

Returns:

  • (Boolean)


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

def belongs_to?
  false
end

#create_with_parent?Boolean

Returns:

  • (Boolean)


76
77
78
# File 'lib/active_scaffold/data_structures/nested_info.rb', line 76

def create_with_parent?
  false
end

#habtm?Boolean

Returns:

  • (Boolean)


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

def habtm?
  false
end

#has_many?Boolean

rubocop:disable Naming/PredicatePrefix

Returns:

  • (Boolean)


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

def has_many? # rubocop:disable Naming/PredicatePrefix
  false
end

#has_one?Boolean

rubocop:disable Naming/PredicatePrefix

Returns:

  • (Boolean)


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

def has_one? # rubocop:disable Naming/PredicatePrefix
  false
end

#match_model?(model) ⇒ Boolean

Returns:

  • (Boolean)


72
73
74
# File 'lib/active_scaffold/data_structures/nested_info.rb', line 72

def match_model?(model)
  false
end

#new_instance?Boolean

Returns:

  • (Boolean)


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

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

#plural_association?Boolean

Returns:

  • (Boolean)


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

def plural_association?
  has_many? || habtm?
end

#readonly?Boolean

Returns:

  • (Boolean)


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

def readonly?
  false
end

#readonly_through_association?(columns) ⇒ Boolean

Returns:

  • (Boolean)


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

def readonly_through_association?(columns)
  false
end

#singular_association?Boolean

Returns:

  • (Boolean)


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

def singular_association?
  belongs_to? || has_one?
end

#sorted?Boolean

Returns:

  • (Boolean)


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

def sorted?(*)
  false
end

#through_association?Boolean

Returns:

  • (Boolean)


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

def through_association?
  false
end

#to_paramsObject



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

def to_params
  {parent_scaffold: parent_scaffold.controller_path}
end