Class: Administrate::Field::Base

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

Direct Known Subclasses

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

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.



31
32
33
34
35
36
37
# File 'lib/administrate/field/base.rb', line 31

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.



51
52
53
# File 'lib/administrate/field/base.rb', line 51

def attribute
  @attribute
end

#dataObject (readonly)

Returns the value of attribute data.



51
52
53
# File 'lib/administrate/field/base.rb', line 51

def data
  @data
end

#optionsObject (readonly)

Returns the value of attribute options.



51
52
53
# File 'lib/administrate/field/base.rb', line 51

def options
  @options
end

#pageObject (readonly)

Returns the value of attribute page.



51
52
53
# File 'lib/administrate/field/base.rb', line 51

def page
  @page
end

#resourceObject (readonly)

Returns the value of attribute resource.



51
52
53
# File 'lib/administrate/field/base.rb', line 51

def resource
  @resource
end

Class Method Details

.associative?Boolean

Returns:



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

def self.associative?
  self < Associative
end

.field_typeObject



23
24
25
# File 'lib/administrate/field/base.rb', line 23

def self.field_type
  to_s.split("::").last.underscore
end

.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:



19
20
21
# File 'lib/administrate/field/base.rb', line 19

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



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

def html_class
  self.class.html_class
end

#nameObject



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

def name
  attribute.to_s
end

#to_partial_pathObject



47
48
49
# File 'lib/administrate/field/base.rb', line 47

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