Class: Adminable::Attributes::Base

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

Overview

Note:

Cannot be initialized

Base class for attributes types

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Base.

Parameters:

  • name (Symbol)

    attribute name e.g. :id or :title

  • options (Hash) (defaults to: {})

    options, see #default_options



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

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

  @name = name.to_sym
  @options = default_options.merge(options)

  @association = Adminable::Attributes::Association.new(
    options[:association]
  ) if options[:association]
end

Instance Attribute Details

#associationObject (readonly)

Returns the value of attribute association.



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

def association
  @association
end

#keyObject (readonly)

Returns the value of attribute key.



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

def key
  @key
end

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

#optionsObject (readonly)

Returns the value of attribute options.



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

def options
  @options
end

#strong_parameterObject (readonly)

Returns the value of attribute strong_parameter.



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

def strong_parameter
  @strong_parameter
end

Instance Method Details

#form_partial_pathObject



42
43
44
# File 'lib/adminable/attributes/base.rb', line 42

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

#index_partial_pathObject



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

def index_partial_path
  "index/#{type}"
end

#ransack_nameObject



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

def ransack_name
  @ransack_name ||= "#{name}_cont"
end

#typeSymbol

Returns class type e.g. :text for Adminable::Attributes::Text.

Returns:

  • (Symbol)

    class type e.g. :text for Adminable::Attributes::Text



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

def type
  @type ||= self.class.name.demodulize.underscore.to_sym
end