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.


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

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


13
14
15
# File 'lib/active_scaffold/data_structures/nested_info.rb', line 13

def association
  @association
end

#child_associationObject

Returns the value of attribute child_association


13
14
15
# File 'lib/active_scaffold/data_structures/nested_info.rb', line 13

def child_association
  @child_association
end

#constrained_fieldsObject

Returns the value of attribute constrained_fields


13
14
15
# File 'lib/active_scaffold/data_structures/nested_info.rb', line 13

def constrained_fields
  @constrained_fields
end

#param_nameObject

Returns the value of attribute param_name


13
14
15
# File 'lib/active_scaffold/data_structures/nested_info.rb', line 13

def param_name
  @param_name
end

#parent_idObject

Returns the value of attribute parent_id


13
14
15
# File 'lib/active_scaffold/data_structures/nested_info.rb', line 13

def parent_id
  @parent_id
end

#parent_modelObject

Returns the value of attribute parent_model


13
14
15
# File 'lib/active_scaffold/data_structures/nested_info.rb', line 13

def parent_model
  @parent_model
end

#parent_scaffoldObject

Returns the value of attribute parent_scaffold


13
14
15
# File 'lib/active_scaffold/data_structures/nested_info.rb', line 13

def parent_scaffold
  @parent_scaffold
end

#scopeObject

Returns the value of attribute scope


13
14
15
# File 'lib/active_scaffold/data_structures/nested_info.rb', line 13

def scope
  @scope
end

Class Method Details

.get(model, params) ⇒ Object


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

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)

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

def belongs_to?
  false
end

#habtm?Boolean

Returns:

  • (Boolean)

30
31
32
# File 'lib/active_scaffold/data_structures/nested_info.rb', line 30

def habtm?
  false
end

#has_many?Boolean

rubocop:disable Naming/PredicateName

Returns:

  • (Boolean)

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

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

#has_one?Boolean

rubocop:disable Naming/PredicateName

Returns:

  • (Boolean)

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

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

#match_model?(model) ⇒ Boolean

Returns:

  • (Boolean)

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

def match_model?(model)
  false
end

#new_instance?Boolean

Returns:

  • (Boolean)

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

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

#plural_association?Boolean

Returns:

  • (Boolean)

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

def plural_association?
  has_many? || habtm?
end

#readonly?Boolean

Returns:

  • (Boolean)

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

def readonly?
  false
end

#readonly_through_association?(columns) ⇒ Boolean

Returns:

  • (Boolean)

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

def readonly_through_association?(columns)
  false
end

#singular_association?Boolean

Returns:

  • (Boolean)

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

def singular_association?
  belongs_to? || has_one?
end

#sorted?Boolean

Returns:

  • (Boolean)

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

def sorted?(*)
  false
end

#through_association?Boolean

Returns:

  • (Boolean)

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

def through_association?
  false
end

#to_paramsObject


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

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