Class: Adminable::Attributes::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/adminable/attributes/base.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, options = {}) ⇒ Base

Returns a new instance of Base.



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/adminable/attributes/base.rb', line 7

def initialize(name, options = {})
  raise 'Base class cannot be initialized' if self.class == Base

  @name = name
  @key = options[:key] || @name
  @ransack_name = "#{@name}_cont"
  @association = options[:association]
  @required = options[:required] || false
  @show = true
  @center = %w(integer boolean float decimal).include?(type)
  @wysiwyg = %w(text).include?(type)
end

Instance Attribute Details

#centerObject Also known as: center?

Returns the value of attribute center.



4
5
6
# File 'lib/adminable/attributes/base.rb', line 4

def center
  @center
end

#keyObject (readonly)

Returns the value of attribute key.



5
6
7
# File 'lib/adminable/attributes/base.rb', line 5

def key
  @key
end

#nameObject

Returns the value of attribute name.



4
5
6
# File 'lib/adminable/attributes/base.rb', line 4

def name
  @name
end

#ransack_nameObject (readonly)

Returns the value of attribute ransack_name.



5
6
7
# File 'lib/adminable/attributes/base.rb', line 5

def ransack_name
  @ransack_name
end

#requiredObject Also known as: required?

Returns the value of attribute required.



4
5
6
# File 'lib/adminable/attributes/base.rb', line 4

def required
  @required
end

#showObject Also known as: show?

Returns the value of attribute show.



4
5
6
# File 'lib/adminable/attributes/base.rb', line 4

def show
  @show
end

#wysiwygObject Also known as: wysiwyg?

Returns the value of attribute wysiwyg.



4
5
6
# File 'lib/adminable/attributes/base.rb', line 4

def wysiwyg
  @wysiwyg
end

Instance Method Details

#form_partial_pathObject



37
38
39
# File 'lib/adminable/attributes/base.rb', line 37

def form_partial_path
  "adminable/resources/form/#{type}"
end

#index_partial_pathObject



33
34
35
# File 'lib/adminable/attributes/base.rb', line 33

def index_partial_path
  "index/#{type}"
end

#strong_parameterObject



29
30
31
# File 'lib/adminable/attributes/base.rb', line 29

def strong_parameter
  key
end

#typeObject



25
26
27
# File 'lib/adminable/attributes/base.rb', line 25

def type
  self.class.name.demodulize.underscore
end