Class: Redress::Utils::ParseAttributesFromParams
- Inherits:
-
Object
- Object
- Redress::Utils::ParseAttributesFromParams
- Defined in:
- lib/redress/utils/parse_attributes_from_params.rb
Instance Method Summary collapse
- #attributes ⇒ Object (also: #to_h)
- #full_prefix ⇒ Object
-
#initialize(klass, params, options = nil) ⇒ ParseAttributesFromParams
constructor
A new instance of ParseAttributesFromParams.
- #model_attributes ⇒ Object
- #prefix ⇒ Object
Constructor Details
#initialize(klass, params, options = nil) ⇒ ParseAttributesFromParams
Returns a new instance of ParseAttributesFromParams.
8 9 10 11 12 |
# File 'lib/redress/utils/parse_attributes_from_params.rb', line 8 def initialize(klass, params, = nil) @klass = klass @params = convert_params_to_hash(params) @options = ( || {}) end |
Instance Method Details
#attributes ⇒ Object Also known as: to_h
14 15 16 |
# File 'lib/redress/utils/parse_attributes_from_params.rb', line 14 def attributes @attributes ||= extract_attributes end |
#full_prefix ⇒ Object
29 30 31 |
# File 'lib/redress/utils/parse_attributes_from_params.rb', line 29 def full_prefix @full_prefix ||= "#{prefix}_" end |
#model_attributes ⇒ Object
19 20 21 |
# File 'lib/redress/utils/parse_attributes_from_params.rb', line 19 def model_attributes @params.fetch(@klass.mimicked_model_name, {}) end |
#prefix ⇒ Object
23 24 25 26 27 |
# File 'lib/redress/utils/parse_attributes_from_params.rb', line 23 def prefix return if @options[:prefix].blank? @prefix ||= @options[:prefix].to_s end |