Module: Netzke::Basepack::DataAccessor
- Defined in:
- lib/netzke/draper/basepack_ext/data_accessor.rb
Instance Method Summary collapse
- #data_adapter ⇒ Object
-
#decorator_class ⇒ Class, FalseClass
Retrieves the decorator class depending on configuration and model class.
Instance Method Details
#data_adapter ⇒ Object
5 6 7 |
# File 'lib/netzke/draper/basepack_ext/data_accessor.rb', line 5 def data_adapter @data_adapter ||= data_class && Netzke::Basepack::DataAdapters::AbstractAdapter.adapter_class(data_class).new(data_class, decorator_class) end |
#decorator_class ⇒ Class, FalseClass
Retrieves the decorator class depending on configuration and model class
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/netzke/draper/basepack_ext/data_accessor.rb', line 13 def decorator_class if @decorator_class.nil? @decorator_class ||= if config[:decorator].is_a?(String) config[:decorator].constantize elsif config[:decorator].is_a?(Class) config[:decorator] elsif config.has_key?(:decorator) false elsif Netzke::Draper::Configuration.decorate_by_default begin "#{data_class}Decorator".constantize rescue NameError false end else false end end @decorator_class end |