Class: Administrate::Field::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/administrate/field/base.rb

Direct Known Subclasses

Associative, Boolean, DateTime, Email, Number, Password, Select, String, Text, Time

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attribute, data, page, options = {}) ⇒ Base

Returns a new instance of Base.



19
20
21
22
23
24
25
# File 'lib/administrate/field/base.rb', line 19

def initialize(attribute, data, page, options = {})
  @attribute = attribute
  @data = data
  @page = page
  @resource = options.delete(:resource)
  @options = options
end

Instance Attribute Details

#attributeObject (readonly)

Returns the value of attribute attribute.



43
44
45
# File 'lib/administrate/field/base.rb', line 43

def attribute
  @attribute
end

#dataObject (readonly)

Returns the value of attribute data.



43
44
45
# File 'lib/administrate/field/base.rb', line 43

def data
  @data
end

#pageObject (readonly)

Returns the value of attribute page.



43
44
45
# File 'lib/administrate/field/base.rb', line 43

def page
  @page
end

#resourceObject (readonly)

Returns the value of attribute resource.



43
44
45
# File 'lib/administrate/field/base.rb', line 43

def resource
  @resource
end

Class Method Details

.html_classObject



11
12
13
# File 'lib/administrate/field/base.rb', line 11

def self.html_class
  field_type.dasherize
end

.permitted_attribute(attr, _options = nil) ⇒ Object



27
28
29
# File 'lib/administrate/field/base.rb', line 27

def self.permitted_attribute(attr, _options = nil)
  attr
end

.searchable?Boolean

Returns:



15
16
17
# File 'lib/administrate/field/base.rb', line 15

def self.searchable?
  false
end

.with_options(options = {}) ⇒ Object



7
8
9
# File 'lib/administrate/field/base.rb', line 7

def self.with_options(options = {})
  Deferred.new(self, options)
end

Instance Method Details

#html_classObject



31
32
33
# File 'lib/administrate/field/base.rb', line 31

def html_class
  self.class.html_class
end

#nameObject



35
36
37
# File 'lib/administrate/field/base.rb', line 35

def name
  attribute.to_s
end

#to_partial_pathObject



39
40
41
# File 'lib/administrate/field/base.rb', line 39

def to_partial_path
  "/fields/#{self.class.field_type}/#{page}"
end