Module: Datagrid::Core::InstanceMethods
- Defined in:
- lib/datagrid/core.rb
Overview
ClassMethods
Instance Method Summary collapse
- #[](attribute) ⇒ Object
- #[]=(attribute, value) ⇒ Object
- #assets ⇒ Object
- #attributes ⇒ Object
- #attributes=(attributes) ⇒ Object
- #check_scope_defined!(message = nil) ⇒ Object
- #driver ⇒ Object
- #initialize(attributes = nil) ⇒ Object
- #paginate(*args, &block) ⇒ Object
- #scope(&block) ⇒ Object
Instance Method Details
#[](attribute) ⇒ Object
79 80 81 |
# File 'lib/datagrid/core.rb', line 79 def [](attribute) self.send(attribute) end |
#[]=(attribute, value) ⇒ Object
83 84 85 |
# File 'lib/datagrid/core.rb', line 83 def []=(attribute, value) self.send(:"#{attribute}=", value) end |
#assets ⇒ Object
87 88 89 |
# File 'lib/datagrid/core.rb', line 87 def assets driver.to_scope(scope) end |
#attributes ⇒ Object
71 72 73 74 75 76 77 |
# File 'lib/datagrid/core.rb', line 71 def attributes result = {} self.datagrid_attributes.each do |name| result[name] = self[name] end result end |
#attributes=(attributes) ⇒ Object
91 92 93 94 95 |
# File 'lib/datagrid/core.rb', line 91 def attributes=(attributes) attributes.each do |name, value| self[name] = value end end |
#check_scope_defined!(message = nil) ⇒ Object
116 117 118 |
# File 'lib/datagrid/core.rb', line 116 def check_scope_defined!( = nil) self.class.send :check_scope_defined!, end |
#driver ⇒ Object
112 113 114 |
# File 'lib/datagrid/core.rb', line 112 def driver self.class.driver end |
#initialize(attributes = nil) ⇒ Object
63 64 65 66 67 68 69 |
# File 'lib/datagrid/core.rb', line 63 def initialize(attributes = nil) super() if attributes self.attributes = attributes end end |
#paginate(*args, &block) ⇒ Object
97 98 99 100 |
# File 'lib/datagrid/core.rb', line 97 def paginate(*args, &block) ::Datagrid::Utils.warn_once("#paginate is deprecated. Call it like object.assets.paginate(...).") self.assets.paginate(*args, &block) end |
#scope(&block) ⇒ Object
102 103 104 105 106 107 108 109 110 |
# File 'lib/datagrid/core.rb', line 102 def scope(&block) if block_given? self.scope_value = block self else check_scope_defined! scope_value.call end end |