Class: Databound::Data
- Inherits:
-
Object
- Object
- Databound::Data
- Defined in:
- lib/databound/data.rb
Instance Method Summary collapse
-
#initialize(controller, json) ⇒ Data
constructor
A new instance of Data.
- #records(model) ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize(controller, json) ⇒ Data
Returns a new instance of Data.
3 4 5 6 7 8 9 10 |
# File 'lib/databound/data.rb', line 3 def initialize(controller, json) return unless json @controller = controller @params = JSON.parse(json) if json.is_a?(String) @params = json if json.is_a?(Hash) @data = interpolated_params end |
Instance Method Details
#records(model) ⇒ Object
12 13 14 |
# File 'lib/databound/data.rb', line 12 def records(model) model.where(@data) end |
#to_h ⇒ Object
16 17 18 |
# File 'lib/databound/data.rb', line 16 def to_h @data end |