Class: UtopiaData::Resource
- Inherits:
-
Object
- Object
- UtopiaData::Resource
- Includes:
- Controllers, Models, Naming, Representer
- Defined in:
- lib/utopia_data/resource.rb,
lib/utopia_data/resource/models.rb,
lib/utopia_data/resource/naming.rb,
lib/utopia_data/resource/controllers.rb,
lib/utopia_data/resource/representer.rb
Defined Under Namespace
Modules: Controllers, Models, Naming, Representer Classes: Name
Instance Attribute Summary collapse
-
#config ⇒ Object
The configuration to resource.
-
#resource_class_name ⇒ Object
readonly
The name of the resource class.
Instance Method Summary collapse
-
#initialize(resource_name, options = {}, &block) ⇒ Resource
constructor
A new instance of Resource.
-
#resource_class ⇒ Object
The class this resource wraps.
- #resource_table_name ⇒ Object
Methods included from Representer
Methods included from Models
#attributes, #columns, #create_resource_model, #model, #model_name, #set
Methods included from Controllers
#controller, #controller_name, #create_resource_controller
Methods included from Naming
#plural_resource_label, #resource_label, #resource_name
Constructor Details
#initialize(resource_name, options = {}, &block) ⇒ Resource
Returns a new instance of Resource.
39 40 41 42 43 44 45 |
# File 'lib/utopia_data/resource.rb', line 39 def initialize(resource_name, = {}, &block) @config ||= {} parse_registration_block(self, &block) if block_given? @resource_class_name = "#{resource_name.to_s.classify}" @options = create! end |
Instance Attribute Details
#config ⇒ Object
The configuration to resource
37 38 39 |
# File 'lib/utopia_data/resource.rb', line 37 def config @config end |
#resource_class_name ⇒ Object (readonly)
The name of the resource class
35 36 37 |
# File 'lib/utopia_data/resource.rb', line 35 def resource_class_name @resource_class_name end |
Instance Method Details
#resource_class ⇒ Object
The class this resource wraps. If you register the Post model, Resource#resource_class will point to the Post class
49 50 51 |
# File 'lib/utopia_data/resource.rb', line 49 def resource_class ActiveSupport::Dependencies.constantize(resource_class_name) end |
#resource_table_name ⇒ Object
53 54 55 |
# File 'lib/utopia_data/resource.rb', line 53 def resource_table_name resource_class.quoted_table_name end |