class Spyro::ActionViewExtension::CollectionForHelper::Parser::Base

Attributes

unicollection[RW]

Public Class Methods

new(collection, helper, options) click to toggle source
# File lib/spyro/collections/parsers/base.rb, line 16
def initialize collection, helper, options
  @h = helper
  @collection = collection
  @options = options

  @unicollection = UniData::Collection.new
  options.each do |key, value|
    @unicollection.add_meta key, value
  end
end

Public Instance Methods

hash_for_name(model, name) click to toggle source
# File lib/spyro/collections/parsers/base.rb, line 33
def hash_for_name model, name
  #value = model[name] # en vrai
  value = model.send(name) # intra

  if name =~ /(.+)_id$/
    model_belong = model.send($1) rescue nil
    if model_belong
      link = link(model_belong) rescue nil
      return {value: model_belong.try(:to_desc) || model_belong.try(:name) || model_belong.id,
              type: String, name: name, db_type: String, link: link}
    end
  end
  {value: value, type: value.class, name: name, db_type: (model.has_attribute?(name) ? model.type_for_attribute(name) : nil)}
end
method_missing(method, args) click to toggle source
# File lib/spyro/collections/parsers/base.rb, line 48
def method_missing method, args
  @unicollection.add_meta method, args
end
parse_default() click to toggle source
# File lib/spyro/collections/parsers/base.rb, line 52
def parse_default
end