Class: ActiveRpc::ModelExtensions::AttributeDsl
- Inherits:
-
Object
- Object
- ActiveRpc::ModelExtensions::AttributeDsl
- Defined in:
- lib/active_rpc/model_extensions/attribute_dsl.rb
Instance Method Summary collapse
- #define_rpc_attribute(name, type, options = {}) ⇒ Object (also: #attribute)
-
#initialize(config) ⇒ AttributeDsl
constructor
A new instance of AttributeDsl.
- #query_config(options = {}) ⇒ Object
- #scope(name, description = nil) ⇒ Object
- #where_rpc_mapping(mappings = {}) ⇒ Object
Constructor Details
#initialize(config) ⇒ AttributeDsl
Returns a new instance of AttributeDsl.
4 5 6 |
# File 'lib/active_rpc/model_extensions/attribute_dsl.rb', line 4 def initialize(config) @config = config end |
Instance Method Details
#define_rpc_attribute(name, type, options = {}) ⇒ Object Also known as: attribute
8 9 10 11 12 |
# File 'lib/active_rpc/model_extensions/attribute_dsl.rb', line 8 def define_rpc_attribute(name, type, = {}) @config.attributes << name.to_sym @config.attribute_types[name.to_sym] = type @config.attribute_defaults[name.to_sym] = [:default] if .key?(:default) end |
#query_config(options = {}) ⇒ Object
16 17 18 |
# File 'lib/active_rpc/model_extensions/attribute_dsl.rb', line 16 def query_config( = {}) @config.query_config = end |
#scope(name, description = nil) ⇒ Object
20 21 22 23 |
# File 'lib/active_rpc/model_extensions/attribute_dsl.rb', line 20 def scope(name, description = nil) @config.scopes ||= {} @config.scopes[name] = { description: description } end |
#where_rpc_mapping(mappings = {}) ⇒ Object
25 26 27 28 |
# File 'lib/active_rpc/model_extensions/attribute_dsl.rb', line 25 def where_rpc_mapping(mappings = {}) @config.where_rpc_mappings ||= {} @config.where_rpc_mappings.merge!(mappings) end |