Class: MegaBar::MegaEnv

Inherits:
Object
  • Object
show all
Defined in:
lib/mega_bar/mega_env.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(blck, rout, page_info, pagination, user = nil) ⇒ MegaEnv

Returns a new instance of MegaEnv.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/mega_bar/mega_env.rb', line 6

def initialize(blck, rout, page_info, pagination, user = nil)
  @user = user
  @block_model_displays = MegaBar::ModelDisplay.by_block(blck.id)
  @displays = blck.actions == "current" ? @block_model_displays.by_block(blck.id).by_action(rout[:action]) : @block_model_displays.by_block(blck.id)
  @block_action = @displays.empty? ? rout[:action] : @displays.first.action
  @modle = MegaBar::Model.by_model(@block_model_displays.first.model_id).first
  @modle_id = @modle.id
  @modyule = @modle.modyule.empty? ? "" : @modle.modyule + "::"
  @kontroller_klass = @modyule + @modle.classname.classify.pluralize + "Controller"
  @kontroller_path = build_kontroller_path
  @klass = (@modyule + @modle.classname.classify).constantize
  @kontroller_inst = @modle.classname.underscore
  @mega_displays = set_mega_displays(@displays)
  @nested_ids, @params_hash_arr, @nested_classes = nest_info(blck, rout, page_info)
  @nested_class_info = set_nested_class_info(@nested_classes)
  @block = blck
  @page_number = pagination.map { |info| info[:page].to_i if info[:kontrlr] == @kontroller_inst + "_page" }.compact.first
end

Instance Attribute Details

#blockObject (readonly)

Returns the value of attribute block.



4
5
6
# File 'lib/mega_bar/mega_env.rb', line 4

def block
  @block
end

#block_actionObject (readonly)

Returns the value of attribute block_action.



4
5
6
# File 'lib/mega_bar/mega_env.rb', line 4

def block_action
  @block_action
end

#klassObject (readonly)

Returns the value of attribute klass.



4
5
6
# File 'lib/mega_bar/mega_env.rb', line 4

def klass
  @klass
end

#kontroller_instObject (readonly)

Returns the value of attribute kontroller_inst.



4
5
6
# File 'lib/mega_bar/mega_env.rb', line 4

def kontroller_inst
  @kontroller_inst
end

#kontroller_klassObject (readonly)

Returns the value of attribute kontroller_klass.



4
5
6
# File 'lib/mega_bar/mega_env.rb', line 4

def kontroller_klass
  @kontroller_klass
end

#kontroller_pathObject (readonly)

Returns the value of attribute kontroller_path.



4
5
6
# File 'lib/mega_bar/mega_env.rb', line 4

def kontroller_path
  @kontroller_path
end

#mega_displaysObject

Returns the value of attribute mega_displays.



4
5
6
# File 'lib/mega_bar/mega_env.rb', line 4

def mega_displays
  @mega_displays
end

#mega_model_propertiesObject

Returns the value of attribute mega_model_properties.



4
5
6
# File 'lib/mega_bar/mega_env.rb', line 4

def mega_model_properties
  @mega_model_properties
end

#modleObject (readonly)

Returns the value of attribute modle.



4
5
6
# File 'lib/mega_bar/mega_env.rb', line 4

def modle
  @modle
end

#modle_idObject (readonly)

Returns the value of attribute modle_id.



4
5
6
# File 'lib/mega_bar/mega_env.rb', line 4

def modle_id
  @modle_id
end

#nested_class_infoObject (readonly)

Returns the value of attribute nested_class_info.



4
5
6
# File 'lib/mega_bar/mega_env.rb', line 4

def nested_class_info
  @nested_class_info
end

#nested_idsObject

Returns the value of attribute nested_ids.



4
5
6
# File 'lib/mega_bar/mega_env.rb', line 4

def nested_ids
  @nested_ids
end

#params_hash_arrObject (readonly)

Returns the value of attribute params_hash_arr.



4
5
6
# File 'lib/mega_bar/mega_env.rb', line 4

def params_hash_arr
  @params_hash_arr
end

Instance Method Details

#to_hashObject



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/mega_bar/mega_env.rb', line 25

def to_hash
  {
    block: @block,
    modle_id: @modle_id,
    mega_model_properties: @modle,
    klass: @klass,
    kontroller_inst: @kontroller_inst,
    kontroller_path: @kontroller_path,
    mega_displays: @mega_displays,
    nested_ids: @nested_ids,
    nested_class_info: @nested_class_info,
    page_number: @page_number,
    user: @user,
  }
end