class Graphoid::Attribute
Constants
- PERMS
Attributes
name[R]
type[R]
Public Class Methods
correct(model, attributes)
click to toggle source
# File lib/graphoid/operators/attribute.rb, line 54 def correct(model, attributes) result = {} fieldnames = fieldnames_of(model) attributes.each do |key, value| key = key.to_s.underscore if fieldnames.exclude?(key.to_s) result[key] = value end result end
fieldnames_of(model, action = :read)
click to toggle source
# File lib/graphoid/operators/attribute.rb, line 39 def fieldnames_of(model, action = :read) fields_of(model, action).map(&:name) end
fields_of(model, action = :read)
click to toggle source
# File lib/graphoid/operators/attribute.rb, line 34 def fields_of(model, action = :read) fields = Graphoid.driver.fields_of(model) + graphields_of(model) fields.select { |field| forbidden_fields_of(model, action).exclude?(field.name) } end
forbidden_fields_of(model, action)
click to toggle source
# File lib/graphoid/operators/attribute.rb, line 47 def forbidden_fields_of(model, action) skips = model.respond_to?(:forbidden_fields) ? model.send(:forbidden_fields) : [] skips.map do |field, actions| field.to_s if actions.empty? || actions.include?(action) end end
graphields_of(model)
click to toggle source
# File lib/graphoid/operators/attribute.rb, line 43 def graphields_of(model) model.respond_to?(:graphields) ? model.send(:graphields) : [] end
new(name:, type:)
click to toggle source
# File lib/graphoid/operators/attribute.rb, line 9 def initialize(name:, type:) @name = name.to_s @camel_name = Utils.camelize(@name) @type = type end
Public Instance Methods
create(_, _, _)
click to toggle source
# File lib/graphoid/operators/attribute.rb, line 31 def create(_, _, _); end
embedded?()
click to toggle source
# File lib/graphoid/operators/attribute.rb, line 19 def embedded? false end
precreate(value)
click to toggle source
# File lib/graphoid/operators/attribute.rb, line 27 def precreate(value) { name.to_sym => value } end
relation?()
click to toggle source
# File lib/graphoid/operators/attribute.rb, line 23 def relation? false end
resolve(o)
click to toggle source
# File lib/graphoid/operators/attribute.rb, line 15 def resolve(o) Graphoid.driver.parse(o.operand, o.value, o.operator) end