Class: Spyro::ActionViewExtension::CollectionForHelper::Parser::Model

Inherits:
Base
  • Object
show all
Defined in:
lib/spyro/collections/parsers/model.rb

Instance Attribute Summary

Attributes inherited from Base

#unicollection

Instance Method Summary collapse

Methods inherited from Base

#hash_for_name, #link, #method_missing, #parse_default

Constructor Details

#initialize(model, helper, options) ⇒ Model

Returns a new instance of Model.



10
11
12
13
14
15
# File 'lib/spyro/collections/parsers/model.rb', line 10

def initialize model, helper, options
  super
  @model = @collection
  @unicollection.add_meta :model_class, model.class
  @unicollection.add_meta :show, polymorphic_path([*options[:parents], model]) rescue nil
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Spyro::ActionViewExtension::CollectionForHelper::Parser::Base

Instance Method Details

#parseObject



17
18
19
20
21
22
23
24
25
26
# File 'lib/spyro/collections/parsers/model.rb', line 17

def parse
  (@unicollection.meta[:data] || @model.attributes).each do |name, val|
    @unicollection.row do |r|
      hash = hash_for_name(@model, name)
      r.add_elem UniData::Element.new(value: name, name: "header", type: String, translate: true)
      r.add_elem UniData::Element.new(hash)
    end
  end

end