Class: CobblesHelper::Cobble

Inherits:
Object
  • Object
show all
Defined in:
app/helpers/cobbles_helper.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cobbler, name, options = {}, &block) ⇒ Cobble

Returns a new instance of Cobble.


8
9
10
11
12
13
14
15
16
17
# File 'app/helpers/cobbles_helper.rb', line 8

def initialize(cobbler, name, options = {}, &block)
  @cobbler = cobbler
  @name = name
  @id = options[:id] || name.to_s.parameterize.dasherize
  @title = options[:title] || @name.tl(default: ["attributes.#{@name}".to_sym, @name.to_s.humanize])
  @@current = self
  @content = @cobbler.template.capture(&block)
  @position = options[:position] || 1000
  @@current = nil
end

Instance Attribute Details

#blockObject (readonly)

Returns the value of attribute block


5
6
7
# File 'app/helpers/cobbles_helper.rb', line 5

def block
  @block
end

#contentObject (readonly)

Returns the value of attribute content


5
6
7
# File 'app/helpers/cobbles_helper.rb', line 5

def content
  @content
end

#idObject (readonly)

Returns the value of attribute id


5
6
7
# File 'app/helpers/cobbles_helper.rb', line 5

def id
  @id
end

#nameObject (readonly)

Returns the value of attribute name


5
6
7
# File 'app/helpers/cobbles_helper.rb', line 5

def name
  @name
end

#positionObject

Returns the value of attribute position


6
7
8
# File 'app/helpers/cobbles_helper.rb', line 6

def position
  @position
end

#titleObject (readonly)

Returns the value of attribute title


5
6
7
# File 'app/helpers/cobbles_helper.rb', line 5

def title
  @title
end

Instance Method Details

#othersObject


19
20
21
# File 'app/helpers/cobbles_helper.rb', line 19

def others
  @cobbler.items.select { |c| c.id != @id }
end