Class: Adminable::Resource

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Resource



6
7
8
9
# File 'lib/adminable/resource.rb', line 6

def initialize(name)
  @name = name
  @model = name.classify.constantize
end

Instance Attribute Details

#attributesArray (readonly)



26
27
28
# File 'lib/adminable/resource.rb', line 26

def attributes
  @attributes
end

#modelObject (readonly)

Returns the value of attribute model.



3
4
5
# File 'lib/adminable/resource.rb', line 3

def model
  @model
end

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/adminable/resource.rb', line 3

def name
  @name
end

Instance Method Details

#==(other) ⇒ Object



30
31
32
# File 'lib/adminable/resource.rb', line 30

def ==(other)
  other.is_a?(Adminable::Resource) && name == other.name
end

#includesArray



17
18
19
20
21
22
23
# File 'lib/adminable/resource.rb', line 17

def includes
  @includes ||= if attributes.associations.present?
                  attributes.associations.map(&:name)
                else
                  false
                end
end

#routeString



12
13
14
# File 'lib/adminable/resource.rb', line 12

def route
  @route ||= @model.name.underscore.pluralize.tr('/', '_')
end