Class: LightParams::Lash
- Inherits:
-
Hash
- Object
- Hash
- LightParams::Lash
show all
- Includes:
- ActiveModel::Serializers::JSON, PropertiesConfiguration
- Defined in:
- lib/light_params/lash.rb
Class Method Summary
collapse
Instance Method Summary
collapse
included, #respond_to?
Constructor Details
#initialize(params = {}) ⇒ Lash
Returns a new instance of Lash.
8
9
10
11
12
|
# File 'lib/light_params/lash.rb', line 8
def initialize(params = {})
LashBuilder.lash_params(self, params).each_pair do |k, v|
self[k.to_sym] = v
end
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class LightParams::PropertiesConfiguration
Class Method Details
.from_json(json, include_root = false) ⇒ Object
18
19
20
21
22
23
24
|
# File 'lib/light_params/lash.rb', line 18
def self.from_json(json, include_root = false)
hash = JSON.parse(json)
hash = hash.values.first if include_root
new(hash)
rescue => e
raise(Errors::JsonParseError, e.message)
end
|
.name ⇒ Object
14
15
16
|
# File 'lib/light_params/lash.rb', line 14
def self.name
@name || super
end
|
Instance Method Details
#attributes ⇒ Object
26
27
28
|
# File 'lib/light_params/lash.rb', line 26
def attributes
OpenStruct.new(keys: self.class.config[:properties])
end
|