Module: SimpleDecorator::Header::ClassMethods

Defined in:
lib/simple_decorator/header.rb

Instance Method Summary collapse

Instance Method Details

#attr_header(*attributes) ⇒ Object



13
14
15
16
17
18
19
20
# File 'lib/simple_decorator/header.rb', line 13

def attr_header(*attributes)
  options = attributes.extract_options!

  self.header_attributes = set attributes
  self.header_link_attributes = set options.fetch(:link, attributes.first)
  self.header_actions = set options[:list_actions]
  self.link_path = options.fetch(:link_path, :edit_resource_path)
end

#headers?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/simple_decorator/header.rb', line 30

def headers?
  header_attributes.present?
end

#link?(field) ⇒ Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/simple_decorator/header.rb', line 22

def link?(field)
  headers? && header_link_attributes.include?(field)
end

#list_action?(action) ⇒ Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/simple_decorator/header.rb', line 26

def list_action?(action)
  list_actions? && header_actions.include?(action)
end

#list_actions?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/simple_decorator/header.rb', line 34

def list_actions?
  header_actions.present?
end

#set(params) ⇒ Object



38
39
40
# File 'lib/simple_decorator/header.rb', line 38

def set(params)
  Set.new Array(params).map(&:to_sym)
end