Class: MegaBar::MegaEnv
- Inherits:
-
Object
- Object
- MegaBar::MegaEnv
- Defined in:
- lib/mega_bar/mega_env.rb
Instance Attribute Summary collapse
-
#block ⇒ Object
readonly
Returns the value of attribute block.
-
#block_action ⇒ Object
readonly
Returns the value of attribute block_action.
-
#klass ⇒ Object
readonly
Returns the value of attribute klass.
-
#kontroller_inst ⇒ Object
readonly
Returns the value of attribute kontroller_inst.
-
#kontroller_klass ⇒ Object
readonly
Returns the value of attribute kontroller_klass.
-
#kontroller_path ⇒ Object
readonly
Returns the value of attribute kontroller_path.
-
#mega_displays ⇒ Object
Returns the value of attribute mega_displays.
-
#mega_model_properties ⇒ Object
Returns the value of attribute mega_model_properties.
-
#modle ⇒ Object
readonly
Returns the value of attribute modle.
-
#modle_id ⇒ Object
readonly
Returns the value of attribute modle_id.
-
#nested_class_info ⇒ Object
readonly
Returns the value of attribute nested_class_info.
-
#nested_ids ⇒ Object
Returns the value of attribute nested_ids.
-
#params_hash_arr ⇒ Object
readonly
Returns the value of attribute params_hash_arr.
Instance Method Summary collapse
-
#initialize(blck, rout, page_info, pagination, user = nil) ⇒ MegaEnv
constructor
A new instance of MegaEnv.
- #to_hash ⇒ Object
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
#block ⇒ Object (readonly)
Returns the value of attribute block.
4 5 6 |
# File 'lib/mega_bar/mega_env.rb', line 4 def block @block end |
#block_action ⇒ Object (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 |
#klass ⇒ Object (readonly)
Returns the value of attribute klass.
4 5 6 |
# File 'lib/mega_bar/mega_env.rb', line 4 def klass @klass end |
#kontroller_inst ⇒ Object (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_klass ⇒ Object (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_path ⇒ Object (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_displays ⇒ Object
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_properties ⇒ Object
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 |
#modle ⇒ Object (readonly)
Returns the value of attribute modle.
4 5 6 |
# File 'lib/mega_bar/mega_env.rb', line 4 def modle @modle end |
#modle_id ⇒ Object (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_info ⇒ Object (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_ids ⇒ Object
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_arr ⇒ Object (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_hash ⇒ Object
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 |