Class: RiddlerAdmin::Element

Inherits:
ApplicationRecord show all
Defined in:
app/models/riddler_admin/element.rb

Constant Summary collapse

MODEL_KEY =
"el".freeze
ID_LENGTH =

56_800_235_584 per second

6

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.available_classesObject



10
11
12
# File 'app/models/riddler_admin/element.rb', line 10

def self.available_classes
  [ Elements::Heading, Elements::Copy ]
end

.default_classObject



14
15
16
# File 'app/models/riddler_admin/element.rb', line 14

def self.default_class
  Elements::Copy
end

.short_nameObject



18
19
20
# File 'app/models/riddler_admin/element.rb', line 18

def self.short_name
  name.demodulize
end

.to_partial_pathObject



22
23
24
# File 'app/models/riddler_admin/element.rb', line 22

def self.to_partial_path
  "#{name.underscore}/class"
end

Instance Method Details

#definition_hash(options = nil) ⇒ Object



39
40
41
42
# File 'app/models/riddler_admin/element.rb', line 39

def definition_hash options=nil
  options ||= {}
  serializable_hash options.merge(serializable_hash_options)
end

#excluded_attrsObject



51
52
53
# File 'app/models/riddler_admin/element.rb', line 51

def excluded_attrs
  [:created_at, :updated_at, :container_type, :container_id, :position, :name]
end

#objectObject

Used in serialization



35
36
37
# File 'app/models/riddler_admin/element.rb', line 35

def object
  type.demodulize.underscore
end

#serializable_hash_optionsObject



44
45
46
47
48
49
# File 'app/models/riddler_admin/element.rb', line 44

def serializable_hash_options
  {
    methods: :object,
    except: excluded_attrs
  }
end

#short_nameObject



30
31
32
# File 'app/models/riddler_admin/element.rb', line 30

def short_name
  self.class.short_name
end

#to_partial_path(detail = nil) ⇒ Object



26
27
28
# File 'app/models/riddler_admin/element.rb', line 26

def to_partial_path detail=nil
  [self.class.name.underscore, detail].compact.join "/"
end