Module: Datagrid::Core::InstanceMethods

Defined in:
lib/datagrid/core.rb

Overview

ClassMethods

Instance Method Summary collapse

Instance Method Details

#[](attribute) ⇒ Object



71
72
73
# File 'lib/datagrid/core.rb', line 71

def [](attribute)
  self.send(attribute)
end

#[]=(attribute, value) ⇒ Object



75
76
77
# File 'lib/datagrid/core.rb', line 75

def []=(attribute, value)
  self.send(:"#{attribute}=", value)
end

#assetsObject



79
80
81
# File 'lib/datagrid/core.rb', line 79

def assets
  scope.scoped({})
end

#attributesObject



63
64
65
66
67
68
69
# File 'lib/datagrid/core.rb', line 63

def attributes
  result = {}
  self.class.datagrid_attributes.each do |name|
    result[name] = self[name]
  end
  result
end

#attributes=(attributes) ⇒ Object



83
84
85
86
87
# File 'lib/datagrid/core.rb', line 83

def attributes=(attributes)
  attributes.each do |name, value|
    self[name] = value
  end
end

#initialize(attributes = nil) ⇒ Object



55
56
57
58
59
60
61
# File 'lib/datagrid/core.rb', line 55

def initialize(attributes = nil)
  super()

  if attributes
    self.attributes = attributes
  end
end

#paginate(*args, &block) ⇒ Object



89
90
91
# File 'lib/datagrid/core.rb', line 89

def paginate(*args, &block)
  self.assets.paginate(*args, &block)
end

#scopeObject



93
94
95
# File 'lib/datagrid/core.rb', line 93

def scope
  self.class.scope
end