Module: LiveResource::Declarations
- Included in:
- Resource
- Defined in:
- lib/live_resource/declarations.rb
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
Instance Method Details
#resource_class ⇒ Object
22 23 24 |
# File 'lib/live_resource/declarations.rb', line 22 def resource_class self.class.instance_variable_get(:@_resource_class) end |
#resource_name ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/live_resource/declarations.rb', line 5 def resource_name # Getting resource name may be expensive, e.g. if it's coming # from Redis. Cache so we don't re-fectch this resource's name # more than once. return @_cached_resource_name if @_cached_resource_name # Class-level resource_name is an attribute we fetch to determine # the instance's name attr = self.class.resource_name_attr if attr @_cached_resource_name = self.send(attr) else raise "can't get resource name for #{self.class.to_s}" end end |