Class: Coupdoeil::Popover::Setup

Inherits:
Object
  • Object
show all
Defined in:
app/models/coupdoeil/popover/setup.rb

Constant Summary collapse

EMPTY_PARAMS =
{}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(klass) ⇒ Setup

Returns a new instance of Setup.



10
11
12
13
14
# File 'app/models/coupdoeil/popover/setup.rb', line 10

def initialize(klass)
  @klass = klass
  @type = nil
  @params = EMPTY_PARAMS
end

Instance Attribute Details

#klassObject (readonly)

Returns the value of attribute klass.



6
7
8
# File 'app/models/coupdoeil/popover/setup.rb', line 6

def klass
  @klass
end

#paramsObject (readonly)

Returns the value of attribute params.



6
7
8
# File 'app/models/coupdoeil/popover/setup.rb', line 6

def params
  @params
end

#typeObject (readonly)

Returns the value of attribute type.



6
7
8
# File 'app/models/coupdoeil/popover/setup.rb', line 6

def type
  @type
end

Instance Method Details

#identifierObject



16
# File 'app/models/coupdoeil/popover/setup.rb', line 16

def identifier = "#{type}@#{klass.popover_resource_name}"

#optionsObject



18
# File 'app/models/coupdoeil/popover/setup.rb', line 18

def options = @options ||= klass.default_options_for(type)

#render_in(view_context) ⇒ Object



17
# File 'app/models/coupdoeil/popover/setup.rb', line 17

def render_in(view_context) = klass.new(params, view_context).process(type)

#with_options(new_options) ⇒ Object



30
31
32
33
# File 'app/models/coupdoeil/popover/setup.rb', line 30

def with_options(new_options)
  @options = options.merge(Popover::OptionsSet.new(new_options))
  self
end

#with_params(**params) ⇒ Object



25
26
27
28
# File 'app/models/coupdoeil/popover/setup.rb', line 25

def with_params(**params)
  @params = params
  self
end

#with_type(type) ⇒ Object



20
21
22
23
# File 'app/models/coupdoeil/popover/setup.rb', line 20

def with_type(type)
  @type = type
  self
end