Class: FlexibleAccessibility::ApplicationResource

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(resource_string) ⇒ ApplicationResource

Returns a new instance of ApplicationResource.



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

def initialize(resource_string)
	@controller = resource_string.split('/').last
	@namespace = resource_string.split('/').first == @controller ? 'default' : resource_string.split('/').first
end

Instance Attribute Details

#controllerObject (readonly)

Returns the value of attribute controller.



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

def controller
  @controller
end

#namespaceObject (readonly)

Returns the value of attribute namespace.



4
5
6
# File 'lib/flexible_accessibility/resource.rb', line 4

def namespace
  @namespace
end

Instance Method Details

#is_standard_resource?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/flexible_accessibility/resource.rb', line 19

def is_standard_resource?
	@namespace == 'default'
end

#klassObject



11
12
13
14
15
16
17
# File 'lib/flexible_accessibility/resource.rb', line 11

def klass
	if self.is_standard_resource?
		@controller.camelize.constantize 
	else
		(@namespace.camelize + '::' + @controller.camelize).constantize
	end
end