Module: Materializer::Base::InstanceMethods
- Defined in:
- lib/materializer/base.rb
Instance Method Summary collapse
-
#from_materialized(options) ⇒ Object
Return content from a materialized profile.
-
#materialize! ⇒ Object
Materialize.
-
#to_materialized_field_name(name) ⇒ Object
Convert a profile name into the column name where we’ll store the data.
Instance Method Details
#from_materialized(options) ⇒ Object
Return content from a materialized profile.
59 60 61 |
# File 'lib/materializer/base.rb', line 59 def from_materialized() self.send(to_materialized_field_name([:profile])) end |
#materialize! ⇒ Object
Materialize.
after_save hook to create all of the rendered json representations based on materialzation profiles.
47 48 49 50 51 52 53 54 55 |
# File 'lib/materializer/base.rb', line 47 def materialize! self.send(:materializers).each do |materializer| using_method = materializer[:using] into_attribute = to_materialized_field_name(materializer[:into]) generated = ActiveSupport::JSON.encode(self.send(using_method.to_sym)) self.send(:update_column, into_attribute, generated) end end |
#to_materialized_field_name(name) ⇒ Object
Convert a profile name into the column name where we’ll store the data.
66 67 68 |
# File 'lib/materializer/base.rb', line 66 def to_materialized_field_name(name) # :nodoc: "#{name}_json" end |