Sha256: 84a1bf92c38e78999b4cb407cfdcc61d7a0645268b66916b3b0a57c7ec62416f
Contents?: true
Size: 1.36 KB
Versions: 3
Compression:
Stored size: 1.36 KB
Contents
Dir[File.dirname(__FILE__) + '/concerns/record/*.rb'].each { |file| require file } class LHS::Record include All include Batch include Configuration include Create include Endpoints include Find include FindBy include First include Mapping include Model include Includes include Request include Where include Pagination delegate :_proxy, to: :_data def initialize(data = nil) data = LHS::Data.new({}, nil, self.class) unless data data = LHS::Data.new(data, nil, self.class) unless data.is_a?(LHS::Data) define_singleton_method(:_data) { data } consider_custom_setters end def as_json(options = nil) _data.as_json(options) end def self.build(data = nil) new(data) end def inspect "<#{self.class}#{_data._raw}>" end protected def method_missing(name, *args, &block) _data._proxy.send(name, *args, &block) end def respond_to_missing?(name, include_all = false) _data.respond_to_missing?(name, include_all) end private def consider_custom_setters return if !instance_data.is_a?(Hash) instance_data.each do |k, v| if public_methods.include?("#{k}=".to_sym) send("#{k}=", v) end end end def instance_data if _data._proxy.is_a?(LHS::Collection) && _data._raw.is_a?(Hash) _data._raw.fetch(:items, []) else _data._raw end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
lhs-3.4.2 | lib/lhs/record.rb |
lhs-3.4.1 | lib/lhs/record.rb |
lhs-3.4.0 | lib/lhs/record.rb |